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"
还有其他选择吗?