Learn R Programming

quanteda (version 0.9.9-3)

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

"as.matrix"(x, ...)
"as.data.frame"(x, row.names = NULL, optional = FALSE, ...)

Arguments

x
dfm to be coerced
...
not used
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.
optional
not applicable to this method

Examples

Run this code
# coercion to matrix
mydfm <- dfm(data_char_inaugural)
str(as.matrix(mydfm))

# coercion to a data.frame
inaugDfm <- dfm(data_char_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