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

-----Original Message-----
From: Thompson, Trevor [mailto:[EMAIL PROTECTED] 
Sent: 13 August 2003 15:47
To: [EMAIL PROTECTED]
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]]

______________________________________________
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help

______________________________________________
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help

Reply via email to