## S3 method for class 'dfm':
cbind(...)## S3 method for class 'dfm':
rbind(...)
cbind
) or
row-wise (rbind
) to the firstcbind(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
does not need to match. The resulting row combined dfm will have its
features alphabetically sorted. The matching is performed by
rbind2
defined for object classes in the
# cbind() for dfm objects
(dfm1 <- dfm("This is one sample text sample.", verbose = FALSE))
(dfm2 <- dfm("More words here.", verbose = FALSE))
cbind(dfm1, dfm2)
# rbind() for dfm objects
(dfm1 <- dfm(c(doc1 = "This is one sample text sample."), verbose = FALSE))
(dfm2 <- dfm(c(doc2 = "One two three text text."), verbose = FALSE))
(dfm3 <- dfm(c(doc3 = "This is the fourth sample text."), verbose = FALSE))
rbind(dfm1, dfm2)
rbind(dfm1, dfm2, dfm3)
Run the code above in your browser using DataLab