【发布时间】:2017-05-23 14:28:51
【问题描述】:
我有以下问题。
table <- data.frame(col1 = c("cars1 gm", "cars2 gl"), col2 = c("cars1 motor mel", "cars2 prom del"))
col1 col2
1 cars1 gm cars1 motor mel
2 cars2 gl cars2 prom del
table$word <- gsub(table$col1, ' ', table$col2)
Warning message: In gsub(table$col1, " ", table$col2) : argument
'pattern' has length > 1 and only the first element will be used
如何创建一个名为word 的新列,其中只包含col2 中没有出现在col1 中的那些值?
col1 col2 word
1 cars1 gm cars1 motor mel motor mel
2 cars2 gl cars2 prom del prom del
【问题讨论】: