从这个过程中
library(stm)
library(tidyr)
library(quanteda)
testDfm <- gadarian$open.ended.response %>%
tokens(remove_punct = TRUE, remove_numbers = TRUE, remove_symbols = TRUE) %>%
dfm()假设我们检查了frq
dftextstat <- textstat_frequency(testDfm)我们想从dfm中删除一些特定的单词。对于dftextstat,我们想要删除c("and", "to"),有什么方法可以使它在dfm中不需要再次运行行来创建dfm?
发布于 2020-11-27 20:04:24
如果您已经有了一个dfm,您可以使用dfm_remove来删除特性。
根据您的例子:
# remove "and" and "to"
testDfm <- dfm_remove(testDfm, c("and", "to"))最好用以下方式移除所有的塞子:
dfm_remove(testDfm, stopwords("english"))如果您仍然有一个令牌对象,您可以以相同的方式使用tokens_remove,或者像上面这样在管道中使用。
https://stackoverflow.com/questions/65042736
复制相似问题