有没有办法使用参数'pattern'length> 1的R gsub函数?

时间:2019-06-07 12:15:07

标签: r gsub

R gsub函数不接受模式长度> 1

例如,如果我运行此命令:

x <- "USA, BR, JP, Earth"
x <- gsub(c("USA","BR","JP"),"country",x)

输出

Warning message:
In gsub(c("USA","BR","JP"),"country",x) :
  argument 'pattern' has length > 1 and only the first element will be used

代替

> x
> "country, country, country, Earth"

还有其他选择吗?

0 个答案:

没有答案