R相交的字符串

时间:2014-03-25 02:18:46

标签: regex r intersect

我将以下数据作为示例:

 basketball = c("MISS W. Johnson 18' Pullup Jump Shot",
                "MISS Barnes 12' Pullup Jump Shot",
                "MISS Carter  19' Pullup Jump Shot")

如何找到最常用的单词或“相交”单词,以便我只有"MISS Pullup Jump Shot"作为结果?

1 个答案:

答案 0 :(得分:9)

这很有效,但我不确定你的问题是多么强大,因为你的问题有点模糊。

Reduce(intersect, strsplit(basketball," "))
#[1] "MISS"   "Pullup" "Jump"   "Shot"