Learn R Programming

quanteda (version 0.99.12)

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

Arguments

x

dfm to be coerced

...

unused

row.names

if FALSE, do not set the row names of the data.frame to the docnames of the dfm (default); or a vector of values to which the row names will be set.

Examples

Run this code
# NOT RUN {
# coercion to matrix
mydfm <- dfm(data_corpus_inaugural)
str(as.matrix(mydfm))

# coercion to a data.frame
inaugDfm <- dfm(data_corpus_inaugural[1:5])
as.data.frame(inaugDfm[, 1:10])
as.data.frame(inaugDfm[, 1:10], row.names = FALSE)
# }

Run the code above in your browser using DataLab