简体   繁体   English

R分组和计数亲和词典

[英]R grouping and counting affinity lexicon

i have a list of words, freq, and affinity lexicon and am trying to count and group, but not sure how to include the frequency in the code.我有一个单词、频率和亲和力词典的列表,我正在尝试计数和分组,但不确定如何在代码中包含频率。 each of these 2 lines works except not counting the freq column in the addition and i'm not sure how to do that.除了不计算加法中的 freq 列之外,这两行中的每一行都有效,我不知道该怎么做。

ddply(summaryLex,~sentiment,summarise,frequency=length(unique(word)))

sqldf("SELECT sentiment, COUNT(sentiment) as totalsent from summaryLex GROUP BY sentiment")
summaryLex csv file][1]

summaryLex File:摘要Lex文件:

[ [摘要Lex文件 ][2 ] https://drive.google.com/open?id=15KBebiqXsNnndOP2mzoaxnvx1nk8Z8vL ][2] https://drive.google.com/open?id=15KBebiqXsNnndOP2mzoaxnvx1nk8Z8vL

if data.table:如果数据表:
data[, sum(freq), by = sentiment]

if dplyr:如果 dplyr:

data %>%
   group_by(sentiment) %>%
   summarise(sum = sum(freq))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM