collapse_tags: Collapse 'term_count' Tags

Description Usage Arguments Value Examples

View source: R/collapse_tags.R

Description

Collapse (sum) tags/columns of a term_count object or remove columns without changing termco class.

Usage

1
collapse_tags(x, mapping, ...)

Arguments

x

A term_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. Setting a column name to NULL deletes these columns from the output.

...

ignored.

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
mapping <- list(
    babbling = c('response_cries', 'back_channels'), #combines these columns
    NULL = 'justification'                           #remove this column(s)
)

data(markers); markers
collapse_tags(markers, mapping)

## Token Counts
token_list <- list(
    list(
        noun__w1.person = c('sam', 'i')
    ),
    list(
        noun__w2.place = c('here', 'house'),
        noun__w3.thing = c('boat', 'fox', 'rain', 'mouse', 'box', 'eggs', 'ham')
    ),
    list(
        negative__w1.no_like = c('not like'),
        noun__w3.thing = c('train', 'goat')
    ),
    list(
        other__w1.other = '^.*$'
    )
)


x <- token_count(sam_i_am, grouping.var = TRUE, token.list = token_list, 
    meta.sep = c('__', '.')) 
    
## drops metatags attribute
## Not run: 
collapse_tags(x, list(ccc = c('noun__w1.person', 'noun__w2.place')))

## End(Not run)

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