[R] remove Punctuation characters

Gabor Grothendieck ggrothendieck at gmail.com
Tue May 9 18:00:58 CEST 2006


You need double [[ and ]]:

gsub('[[:punct:]]','',str)

On 5/9/06, Filipe Almeida <milheiros at gmail.com> wrote:
> Hi,
>
> I want to remove all punctuation characters in a string. I was trying it use
> a regular expressions but it doesn't work.
> Here is a sample os what i want:
>
> str <- 'ABD - remove de punct, and dot characters.'
> str <- gsub('[:punct:]','',str)
> str
> "'ABD remove de punct and dot characters"
>
> is there any function that do this kind of thing?
>
> Thanks to all.
>
> Filipe Almeida
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>




More information about the R-help mailing list