Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
可能重复: 如何从 R 中的字符串中删除所有空格?
我有一个字符串
c<-"abc def gh"
我需要从这个字符串中删除每个空格并得到 sth 喜欢
c<-"abcdefgh"
如何在 r 中做到这一点?
使用gsub():
gsub()
gsub(" ", "", c) gsub("[[:space:]]", "", c)
library(stringr) str_replace_all(c, " ", "")