> pname <- "Ratchanon \"TK\" Chantananuwat (Am)"
> gsub(\"TK\", "", pname)
Error: unexpected string constant in "gsub(\"TK\", ""
可以删除\"TK\"
这个人的名字吗?
在base R
:
gsub('\\"TK\\"', "", pname)
#> [1] "Ratchanon Chantananuwat (Am)"
另一种可能的解决方案,基于stringr::str_replace
:
library(stringr)
str_remove(pname, '\\"TK\\"')
#> [1] "Ratchanon Chantananuwat (Am)"
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句