我有一个返回两个列变量的数据框 - word1 和 word2 像这样:
head(bigrams_filtered2, 20)
# A tibble: 20 x 2
word1 word2
<chr> <chr>
1 practice risk
2 risk management
3 management rational
4 rational meansend
5 meansend based
6 based process
7 process risks
8 risks identified
9 identified analysed
10 analysed solved
11 solved mitigated
12 objective involves
13 involves human
14 human perceptions
15 perceptions biases
16 opportunity jack
17 differences stakeholder
18 stakeholder perceptions
19 perceptions broader
20 broader risk
我正在尝试向此 data.frame 添加两个额外的列变量,以便我的输出如下所示:
## word1 word2 n totalbigrams tf
## 1 st louis 1930 3426965 0.0005631805
## 2 happy birthday 1802 3426965 0.0005258297
## 3 1 2 1701 3426965 0.0004963576
## 4 los angeles 1385 3426965 0.0004041477
## 5 social media 1256 3426965 0.0003665051
## 6 san francisco 1245 3426965 0.0003632952
我从这里http://www.rpubs.com/pnice421/347328跟随一个例子
在“生成二元组”标题下,他们提供了以下代码作为实现此目的的一种方式,但我返回一个错误:
totalbigrams <- bigrams_filtered2 %>%
summarize(total=sum(n))
Error in summarise_impl(.data, dots) :
Evaluation error: invalid 'type' (closure) of argument.
如果有人对我可能出错的地方有任何建议,将不胜感激!谢谢你。