set_meta_tags: Set Meta Tags Attribute on a 'term_count'/'token_count'...

Description Usage Arguments Value Examples

View source: R/set_meta_tags.R

Description

Set the metatags attribute on a term_count/token_count object. Meta tags called in tidy_counts.

Usage

1
2
3
4
5
6
7
set_meta_tags(x, tags, ...)

## S3 method for class 'data.frame'
set_meta_tags(x, tags, ...)

## S3 method for class 'list'
set_meta_tags(x, tags, ...)

Arguments

x

A term_count/token_count object.

tags

A data.frame with a 'tag' column corresponding to the tag columns in the term_count/token_count object. Can also take a named list but only allows for tags and meta tags where as the number of tag levels is unrestricted if passing a data.frame.

...

ignored.

Value

Returns a term_count/token_count object with the metatags attribute set.

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
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)
attributes(x)[['metatags']]

tag_list <- list(
    noun = c('person', 'place', 'thing'),
    odd_ones = c('other', 'no_like')
)

library(textshape)

tag_df <- tidy_list(list(
    noun = c('person', 'place', 'thing'),
    odd_ones = c('other', 'no_like')
), 'meta', 'tag')[, 2:1]

x2 <- set_meta_tags(x, tag_list)
attributes(x2)[['metatags']]

x3 <- set_meta_tags(x, tag_df)
attributes(x3)[['metatags']]

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