【发布时间】:2015-02-01 22:26:02
【问题描述】:
我有一个看起来像这样的向量
vector = c('hello, how are you, I am good',
'the sky is blue, isnt that nice')
我想删除逗号后的每个 ' ' 中的空格
即输出应如下所示:
'hello,how are you,I am good','the sky is blue,isnt that nice'
【问题讨论】:
-
gsub(",\\s", ",", vector) -
或者只是为了好玩
gsub("(?<=,)\\s", "", vector, perl = TRUE)