【发布时间】:2017-04-16 20:36:42
【问题描述】:
使用 tidytext,我有这个代码:
data(stop_words)
tidy_documents <- tidy_documents %>%
anti_join(stop_words)
我希望它使用包中内置的停用词将名为 tidy_documents 的数据帧写入同名数据帧,但如果它们在 stop_words 中,则将其删除。
我收到此错误:
错误:没有公共变量。请指定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参数来匹配这两个数据集。 -
stop_words的列被称为word,因此要么命名你的列,要么使用anti_join的by参数。 -
tidy_documents中的列名是什么?如果您分享,我们可以具体告诉您如何设置加入。 -
@JuliaSilge
tidy_documents中的列是 `author;日期;词'。 -
@textnet 嗯,那看起来很奇怪。如果您的主数据集中有
word列,我希望anti_join()知道将其与stop_words数据集中的word列匹配。可以试试make a reproducible example 有数据吗?
标签: r dplyr tidyverse tidytext