我需要从文本中删除标点符号。我正在使用tm包,但问题是:
比如:文本内容如下:
data <- "I am a, new comer","to r,"please help","me:out","here"
现在当我运行时
library(tm)
data<-removePunctuation(data)
我的代码输出结果是:
I am a new comerto rplease helpmeouthere
但是我期望的是:
I am a new comer to r please help me out here
c()
函数并将这几个字符串放在一起吗?还是这只是一个长字符串(根据你想要的输出推断)。无论哪种情况,你可以尝试使用类似于gsub("[[:punct:]]", " ", data)
的方法。 - David Arenburg