Learn R Programming

mclm (version 0.2.7)

tot_n_tokens: Retrieve or set the total number of tokens

Description

These methods retrieve or set the total number of tokens in the corpus on which the frequency counts are based. This total number of tokens may be higher than the sum of all frequency counts in x, for instance, if x contains frequency counts for a selection of items only, and not for all tokens in the corpus.

Usage

tot_n_tokens(x)

tot_n_tokens(x) <- value

# S3 method for freqlist tot_n_tokens(x) <- value

# S3 method for freqlist tot_n_tokens(x)

Value

A number.

Arguments

x

An object of any of the classes for which the method is implemented.

value

Numerical value.

See Also

Other getters and setters: n_tokens(), n_types(), orig_ranks(), ranks(), type_names()

Examples

Run this code
x <- freqlist("The man and the mouse.",
              re_token_splitter = "(?xi) [:\\s.;,?!\"]+",
              as_text = TRUE)
x
tot_n_tokens(x)

y <- keep_types(x, c("man", "and"))
tot_n_tokens(y)
y

tot_n_tokens(y) <- sum(y)
y
tot_n_tokens(y)

Run the code above in your browser using DataLab