Build data and AI skills | 50% off

Last chance! 50% off unlimited learning

Sale ends in


quanteda (version 0.9.9-50)

as.tokens.collocations: coercion and checking functions for tokens objects

Description

Coerce a list of character elements to a quanteda tokens object, or check whether an object is a tokens object.

Usage

# S3 method for collocations
as.tokens(x)

as.tokens(x)

# S3 method for list as.tokens(x)

# S3 method for tokens as.list(x, ...)

# S3 method for tokens as.character(x, use.names = FALSE, ...)

is.tokens(x)

# S3 method for tokens +(t1, t2)

# S3 method for tokens c(..., recursive = FALSE)

Arguments

x
list of character elements
...
unused
use.names
logical; preserve names if TRUE. For as.character only.
t1
tokens one to be added
t2
tokens two to be added
recursive
logical used by `c()` method, always set to `FALSE`

Value

as.tokens returns a quanteda tokens object

as.list returns a simple list of characters from a tokens object

as.character returns a character vector from a tokens object

is.tokens returns TRUE if the object is of class tokens, FALSE otherwise.

Examples

Run this code
toks1 <- tokens(data_corpus_inaugural[1:5])
toks2 <- tokens(data_corpus_inaugural[21:25])
toks3 <- toks1 + toks2


toks1 <- tokens(data_corpus_inaugural[1:5])
toks2 <- tokens(data_corpus_inaugural[21:25])
toks3 <- tokens(data_corpus_inaugural[41:45])
summary(c(toks1, toks2, toks3))

Run the code above in your browser using DataLab