tCorpus-cash-set_levels: Change levels of factor columns

Description Arguments Details Examples

Description

For factor columns, the levels can be changed directly (and by reference). This is particularly usefull for fast preprocessing (e.g., making tokens lowercase, )

Arguments

column

the name of the column

levels

The new levels

Details

Usage:

## R6 method for class tCorpus. Use as tc$method (where tc is a tCorpus object).

1
set_levels(column, levels)
1

Examples

1
2
3
4
5
6
tc = create_tcorpus(c('Text one first sentence. Text one second sentence', 'Text two'))

## change factor levels of a column in the token data
unique_tokens <- tc$get_levels('token')
tc$set_levels('token', toupper(unique_tokens))
tc$get()

kasperwelbers/corpustools documentation built on Dec. 5, 2018, 9:11 a.m.