Im quite new to quanteda and R. Is theyr any chance to merge multiple DFMs rowwise?
I do have at least 3 dfms with multiple texts in them and want to merge them into one dfm.
Im quite new to quanteda and R. Is theyr any chance to merge multiple DFMs rowwise?
I do have at least 3 dfms with multiple texts in them and want to merge them into one dfm.
You can use rbind
to combine them together.
Small example:
library(quanteda)
dfm1 <- data_corpus_inaugural %>%
corpus_subset(Year > 1990) %>%
tokens() %>%
dfm()
dfm2 <- data_corpus_inaugural %>%
corpus_subset(Year <= 1990 & Year > 1980) %>%
tokens() %>%
dfm()
dfm_combined <- rbind(dfm1, dfm2)
If needed you can run dfm_compress
afterwards if you notice that there are features or documents that occur in both dfms. Check the help with ?dfm_combined
.