使用tidytext,我有如下代码:
我希望它使用包中内置的停用词,将一个名为tidy_documents的数据框写入到同名的数据框中,但如果这些单词在停用词中,则将其删除。
我得到了以下错误:
错误:没有公共变量。请指定“by”参数。 回溯:
data(stop_words)
tidy_documents <- tidy_documents %>%
anti_join(stop_words)
我希望它使用包中内置的停用词,将一个名为tidy_documents的数据框写入到同名的数据框中,但如果这些单词在停用词中,则将其删除。
我得到了以下错误:
错误:没有公共变量。请指定“by”参数。 回溯:
1. tidy_documents %>% anti_join(stop_words)
2. withVisible(eval(quote(`_fseq`(`_lhs`)), env, env))
3. eval(quote(`_fseq`(`_lhs`)), env, env)
4. eval(expr, envir, enclos)
5. `_fseq`(`_lhs`)
6. freduce(value, `_function_list`)
7. withVisible(function_list[[k]](value))
8. function_list[[k]](value)
9. anti_join(., stop_words)
10. anti_join.tbl_df(., stop_words)
11. common_by(by, x, y)
12. stop("No common variables. Please specify `by` param.", call. = FALSE)
tidy_documents
和stop_words
没有共享任何变量名称,因此您需要使用by
参数匹配这两个数据集。 - Axemanstop_words
列被称为word
,因此请使用该名称命名您的列或使用anti_join
函数的by
参数。 - alistairetidy_documents
中的列是作者; 日期; 单词
。 - Simon Lindgrenword
列,我希望anti_join()
会知道将其与stop_words
数据集中的word
列匹配起来。您能否尝试使用数据生成可再现的示例? - Julia Silgedata(stop_words) tidy_base <- anti_join(tidy_base, stop_words, by="word")
。看起来合理吗? - Simon Lindgren