[R] Flummoxed by gsub().

Stefan Evert stefanML at collocations.de
Wed Aug 23 08:33:27 CEST 2017


> On 23 Aug 2017, at 07:45, Rolf Turner <r.turner at auckland.ac.nz> wrote:
> 
> My reading of ?regex led me to believe that
> 
>    gsub("[:alpha:]","",x)
> 
> should give the result that I want. 

That's looking for any of the characters a, l, p, h, : .

What you meant to say was

	gsub("[[:alpha:]]","",x)

i.e. the character class [:alpha:] within a character set.

Best,
Stefan



More information about the R-help mailing list