categorize: Merge Clusters & Cluster Categories Back to Original Data

Description Usage Arguments Value See Also Examples

Description

Merge clusters, categories, and the original data back together.

Usage

1
categorize(data, assign.cluster, cluster.key)

Arguments

data

A data set that was fit with a cluster model.

assign.cluster

An assign_cluster object.

cluster.key

An assign_cluster object.

Value

Returns a data.frame key of clusters and categories.

See Also

write_cluster_text, read_cluster_text

Examples

 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
)

trinker/clustext documentation built on May 31, 2019, 8:41 p.m.