[R] Regexpr with "."

David Khabie-Zeitoune dave at evocapital.com
Wed Aug 13 16:57:23 CEST 2003


Try regexpr("\\.", "Female.Alabama")

-----Original Message-----
From: Thompson, Trevor [mailto:tkt2 at cdc.gov] 
Sent: 13 August 2003 15:47
To: r-help at stat.math.ethz.ch
Subject: [R] Regexpr with "."


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. For example,

> regexpr(".", "Female.Alabama")
[1] 1
attr(,"match.length")
[1] 1

In trying to figure out what was going on here, I tried the below
command:

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

It looks like R is treating every character in the string as if it were
decimal.  I didn't see anything in the help file about "." being some
kind of special character.  Any idea why R is treating a decimal this
way in
these functions?   Any suggestions how to get around this?

Thanks for any suggestions.

-Trevor
 


	[[alternative HTML version deleted]]

______________________________________________
R-help at stat.math.ethz.ch mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help




More information about the R-help mailing list