1
我要循环到另一个列表匹配单词的两个列表,并通过字符串列表返回匹配的话
cutter_Ch <- c('happy','birthday','Lucia')
pos <- c('Lucia','today')
一个办法,我可以做到这一点是与lapply
pos.matches = lapply(cutter_Ch, pmatch, pos)
[[1]]
[1] NA
[[2]]
[1] NA
[[3]]
[1] 1
然而,我想要函数返回匹配的字符串而不是NA和次数匹配,像这样
[[1]]
[1] NA
[[2]]
[1] NA
[[3]]
[1] Lucia