tCorpus$set_levels {corpustools}R Documentation

Change levels of factor columns

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).

set_levels(column, levels)
set_meta_levels(column, levels)

Examples

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$tokens

[Package corpustools version 0.4.10 Index]