combine_counts: Combine 'term_count' and 'token_count' Objects

Description Usage Arguments Value Examples

View source: R/combine_counts.R

Description

Combine term_count and token_count objects.

Usage

1
combine_counts(x, y, mapping = NULL, ...)

Arguments

x

A term_count or token_count object.

y

A term_count or token_count object.

mapping

A list of named vectors where the vector names are the collapsed column names and the vectors are the names of the columns to collapse. The default, NULL, combines columns with the same name in both x and y.

...

ignored.

Value

Returns a combine_counts object.

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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
## Not run: 
token_list <- list(
    list(
        person = c('sam', 'i')
    ),
    list(
        place = c('here', 'house'),
        thing = c('boat', 'fox', 'rain', 'mouse', 'box', 'eggs', 'ham')
    ),
    list(
        no_like = c('not like'),
        thing = c('train', 'goat')
    )
)

(y <- token_count(sam_i_am, grouping.var = TRUE, token.list = token_list))


term_list <- list(
    list(Is = c("I")),
    list(
        oulds = c("ould"),
        thing = c('egg', 'ham')
    )
)


(x <-term_count(sam_i_am, grouping.var = TRUE, term_list, ignore.case = FALSE))

combine_counts(x, y)
combine_counts(y, x)

library(lexicon)
library(textshape)
library(dplyr)

token_list <- lexicon::nrc_emotions %>%
    textshape::column_to_rownames() %>%
    t() %>%
    textshape::as_list()


a <- presidential_debates_2012 %>%
     with(token_count(dialogue, list(person, time), token_list))

term_list <- list(
    response_cries = c("\\boh", "\\bah", "\\baha", "\\bouch", "yuk"),
    back_channels = c("uh[- ]huh", "uhuh", "yeah"),
    summons = "hey",
    justification = "because"
)

b <- presidential_debates_2012 %>%
     with(term_count(dialogue, list(person, time), term_list))

combine_counts(a, b)
combine_counts(b, a)


d <- sam_i_am %>%
     term_count(TRUE, token_list[1:2])

e <- sam_i_am %>%
     term_count(TRUE, token_list[[3]])


combine_counts(e, d)

## End(Not run)

trinker/termco documentation built on Jan. 7, 2022, 3:32 a.m.