【发布时间】:2018-07-08 06:32:39
【问题描述】:
如果我有一个包含以下列的数据框:
df$text <- c("This string is not that long", "This string is a bit longer but still not that long", "This one just helps with the example")
还有这样的字符串:
keywords <- c("not that long", "This string", "example", "helps")
我正在尝试向我的数据框添加一列,其中包含每行文本中存在的关键字列表:
df$关键字:
1 c("This string","not that long")
2 c("This string","not that long")
3 c("helps","example")
虽然我不确定如何 1) 从文本列中提取匹配的单词,以及 2) 如何在新列的每一行中列出匹配的单词
【问题讨论】: