Methods for coercing a dfm object to a matrix or data.frame object.
# S3 method for dfm as.matrix(x, ...) # S3 method for dfm as.data.frame(x, row.names = NULL, ..., document = docnames(x), check.names = FALSE)
x | dfm to be coerced |
---|---|
... | unused |
row.names |
|
document | optional first column of mode |
check.names | logical. If |
# coercion to matrix as.matrix(data_dfm_lbgexample[, 1:10])#> features #> docs A B C D E F G H I J #> R1 2 3 10 22 45 78 115 146 158 146 #> R2 0 0 0 0 0 2 3 10 22 45 #> R3 0 0 0 0 0 0 0 0 0 0 #> R4 0 0 0 0 0 0 0 0 0 0 #> R5 0 0 0 0 0 0 0 0 0 0 #> V1 0 0 0 0 0 0 0 2 3 10# coercion to a data.frame as.data.frame(data_dfm_lbgexample[, 1:15])#> document A B C D E F G H I J K L M N O #> 1 R1 2 3 10 22 45 78 115 146 158 146 115 78 45 22 10 #> 2 R2 0 0 0 0 0 2 3 10 22 45 78 115 146 158 146 #> 3 R3 0 0 0 0 0 0 0 0 0 0 2 3 10 22 45 #> 4 R4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 #> 5 R5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 #> 6 V1 0 0 0 0 0 0 0 2 3 10 22 45 78 115 146as.data.frame(data_dfm_lbgexample[, 1:15], document = NULL)#> A B C D E F G H I J K L M N O #> 1 2 3 10 22 45 78 115 146 158 146 115 78 45 22 10 #> 2 0 0 0 0 0 2 3 10 22 45 78 115 146 158 146 #> 3 0 0 0 0 0 0 0 0 0 0 2 3 10 22 45 #> 4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 #> 5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 #> 6 0 0 0 0 0 0 0 2 3 10 22 45 78 115 146as.data.frame(data_dfm_lbgexample[, 1:15], document = NULL, row.names = docnames(data_dfm_lbgexample))#> A B C D E F G H I J K L M N O #> R1 2 3 10 22 45 78 115 146 158 146 115 78 45 22 10 #> R2 0 0 0 0 0 2 3 10 22 45 78 115 146 158 146 #> R3 0 0 0 0 0 0 0 0 0 0 2 3 10 22 45 #> R4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 #> R5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 #> V1 0 0 0 0 0 0 0 2 3 10 22 45 78 115 146