Learn R Programming

quanteda (version 1.1.1)

as.matrix.dfm: Coerce a dfm to a matrix or data.frame

Description

Methods for coercing a dfm object to a matrix or data.frame object.

Usage

# S3 method for dfm
as.matrix(x, ...)

# S3 method for dfm as.data.frame(x, row.names = NULL, ..., document = docnames(x), check.names = FALSE)

Arguments

x

dfm to be coerced

...

unused

row.names

NULL or a character vector giving the row names for the data frame. Missing values are not allowed.

document

optional first column of mode character in the data.frame, defaults docnames(x). Set to NULL to exclude.

check.names

logical. If TRUE then the names of the variables in the data frame are checked to ensure that they are syntactically valid variable names and are not duplicated. If necessary they are adjusted (by make.names) so that they are.

Examples

Run this code
# NOT RUN {
# coercion to matrix
as.matrix(data_dfm_lbgexample[, 1:10])

# coercion to a data.frame
as.data.frame(data_dfm_lbgexample[, 1:15])
as.data.frame(data_dfm_lbgexample[, 1:15], document = NULL)
as.data.frame(data_dfm_lbgexample[, 1:15], document = NULL, 
              row.names = docnames(data_dfm_lbgexample))
# }

Run the code above in your browser using DataLab