select_counts: Apply Normalization to Term/Token Columns

Description Usage Arguments Value Examples

View source: R/select_counts.R

Description

Apply normalization to a term count columns of termco object without stripping the class & attributes of the object.

Usage

1

Arguments

x

A term_count object.

...

One or more unquoted expressions separated by commas. You can treat variable names like they are positions. See ?dplyr::select for more information on ....

Value

Returns a term_count 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
70
71
72
## Not run: 
library(dplyr)

term_list <- list(
    `if` = c('if'),
    ands = c('an'),
    or = c('or'),
    buts = c('but')
)

out <- presidential_debates_2012 %>%
     with(term_count(dialogue, TRUE, term_list))

out

out %>%
    select_counts(-or)

out %>%
    select_counts(-c(ands:buts))
    
out %>%
    select_counts(n.words, ands:buts)
    
## Can't print as a term_count object (n n.words)
out %>%
    select_counts(ands:buts)
    
## Token Counts
token_list2 <- 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'),
        other = c('in')
    ),
    list(
        other = 'i'
    )
)


x <- token_count(sam_i_am, grouping.var = TRUE, token.list = token_list2)

x %>%
    select_counts(-thing)
    
x %>%
    select_counts(-c(person, other))
    
## Handles metatags
tag_list <- list(
    noun = c('person', 'place', 'thing'),
    odd_ones = c('other', 'no_like')
)

x2 <- set_meta_tags(x, tag_list)

x2 %>%
    tidy_counts()
    
x2 %>%
    select_counts(-c(person, other))%>%
    tidy_counts()

## End(Not run)

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