Description Usage Arguments See Also Examples
Write cluster text from get_text(assign_cluster(myfit))
to an external
file for categorization. After file has been written with
write_cluster_text
a human coder can assign categories to each cluster.
Simple write the category after the Cluster #:
. To set a cluster category
equal to another simply write and equal sign follwed by the other cluster to set
as the same category (e.g., Cluster 10: =5
to set cluster #10 the same as
cluster #5). See readLines(system.file("additional/foo_turk.txt", package = "clustext"))
for an example.
1 2 3 | write_cluster_text(x, path, n.sample = NULL, lead = " * ", ...)
read_cluster_text(path, ...)
|
x |
An |
path |
A pather to the file (.txt) is recommended. |
n.sample |
The length to limit the sample to (default gives all text in the cluster). Setting this to an integer uses this as the number to randomly sample from. |
lead |
A leading character string prefix to give the cluster text. |
... |
ignored. |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | library(dplyr)
## Assign Clusters
ca <- presidential_debates_2012 %>%
with(data_store(dialogue)) %>%
hierarchical_cluster() %>%
assign_cluster(k = 7)
## Write Cluster Text for Human Categorization
write_cluster_text(ca)
write_cluster_text(ca, n.sample=10)
write_cluster_text(ca, lead=" -", n.sample=10)
## Read Human Coded Categories Back In
categories_file <- system.file("additional/foo_turk.txt", package = "clustext")
readLines(categories_file)
(categories_key <- read_cluster_text(categories_file))
## Add Categories Back to Original Data Set
categorize(
data = presidential_debates_2012,
assign.cluster = ca,
cluster.key = categories_key
)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.