[R] Regexpr with "."

Jeff Gentry jgentry at jimmy.harvard.edu
Wed Aug 13 16:57:40 CEST 2003

> I'm trying to use the regexpr function to locate the decimal in a character
> string.  Regardless of the position of the decimal, the function returns 1.

You need to escape it.

> gsub("\\.",",","Female.Alabama")
[1] "Female,Alabama"

More information about the R-help mailing list