cbind.dfm | R Documentation |
Combine a dfm with another dfm, or numeric, or matrix object, returning a dfm with the combined documents or features, respectively.
## S3 method for class 'dfm'
cbind(...)
## S3 method for class 'dfm'
rbind(...)
... |
dfm, numeric, or matrix objects to be joined column-wise
( |
cbind(x, y, ...)
combines dfm objects by columns, returning a
dfm object with combined features from input dfm objects. Note that this
should be used with extreme caution, as joining dfms with different
documents will result in a new row with the docname(s) of the first dfm,
merging in those from the second. Furthermore, if features are shared
between the dfms being cbinded, then duplicate feature labels will result.
In both instances, warning messages will result.
rbind(x, y, ...)
combines dfm objects by rows, returning a
dfm object with combined features from input dfm objects. Features are
matched between the two dfm objects, so that the order and names of the
features do not need to match. The order of the features in the resulting
dfm is not guaranteed. The attributes and settings of this new dfm are not
currently preserved.
# cbind() for dfm objects
(dfmat1 <- dfm(tokens(c("a b c d", "c d e f"))))
(dfmat2 <- dfm(tokens(c("a b", "x y z"))))
cbind(dfmat1, dfmat2)
cbind(dfmat1, 100)
cbind(100, dfmat1)
cbind(dfmat1, matrix(c(101, 102), ncol = 1))
cbind(matrix(c(101, 102), ncol = 1), dfmat1)
# rbind() for dfm objects
(dfmat1 <- dfm(tokens(c(doc1 = "This is one sample text sample."))))
(dfmat2 <- dfm(tokens(c(doc2 = "One two three text text."))))
(dfmat3 <- dfm(tokens(c(doc3 = "This is the fourth sample text."))))
rbind(dfmat1, dfmat2)
rbind(dfmat1, dfmat2, dfmat3)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.