as_topic: Convert 'get_terms' to Topics

Description Usage Arguments Value Examples

Description

View important terms as a comma separated string (a topic).

Usage

1
2
3
4
as_topic(x, max.n = 8, sort = TRUE, ...)

## S3 method for class 'get_terms'
as_topic(x, max.n = 8, sort = TRUE, ...)

Arguments

x

A get_terms object.

max.n

The max number of words to show before truncation.

sort

logical. If TRUE the cluster topics are sorted by size (number of documents) otherwise the topics are sorted by cluster number.

...

ignored.

Value

Returns a data.frame of "cluster", "count", and "terms". Pretty prints as clusters, number of documents, and associated important terms.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
library(dplyr)

myfit5 <- presidential_debates_2012 %>%
    mutate(tot = gsub("\\..+$", "", tot)) %>%
    textshape::combine() %>%
    filter(person %in% c("ROMNEY", "OBAMA")) %>%
    with(data_store(dialogue, stopwords = tm::stopwords("english"), min.char = 3)) %>%
    hierarchical_cluster()

ca5 <- assign_cluster(myfit5, k = 50)

get_terms(ca5, .4) %>%
    as_topic()

get_terms(ca5, .4) %>%
    as_topic(sort=FALSE)

get_terms(ca5, .95) %>%
    as_topic()

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