2017-09-02 72 views
0

我有如下数据集:在所有数据集的最频繁出现的词汇

interests<-data.frame(interests=c("A mentor/teacher,Friendship", 
         "A play partner,Princess by day slut by night,Friendship,A sub,A slave", 
         "A relationship,A play partner,Friendship,Events", 
         "Not Defined")) 

所以数据集如下:

interests 
<fctr> 
A mentor/teacher,Friendship 
A play partner,Princess by day slut by night,Friendship,A sub,A slave 
A relationship,A play partner,Friendship,Events 
Not Defined 

我需要知道,多少次每学期在数据集中重复?

例如在“友谊”已经重复倍,但“一出戏的合作伙伴”已经reapeated 倍,其余的都重复一次。

我已经看到类似的问题,如this,但问题是条款的长度是不同的。

回答

3
table(unlist(strsplit(as.character(interests$interests), split="\\W"))) 

,或者因为你似乎认为 “一出戏的合作伙伴” 一个词:

table(unlist(strsplit(as.character(interests$interests), split=",")))