【发布时间】:2017-09-25 11:44:15
【问题描述】:
我有
words <- c("word1", "word")
text <- c("this is word1", "this is word2", "this is word4")
如果我使用sapply(words, grepl, text) 给你正确和错误的答案,
相反,我怎样才能得到匹配的确切单词
这样答案就是
"this is word1"
我是 R 的新手,请原谅这种愚蠢的问题。 欢迎任何想法。
【问题讨论】:
-
sapply(words, grep, text, value = TRUE)?