Try regexpr("\\.", "Female.Alabama") and gsub("\\.", ",", "Female.Alabama")
>X-Sybari-Trust: 9293cd92 d90ef28b 235e1558 0000093d >From: "Thompson, Trevor" <[EMAIL PROTECTED]> >To: [EMAIL PROTECTED] >Date: Wed, 13 Aug 2003 10:46:45 -0400 >MIME-Version: 1.0 >X-Virus-Scanned: by amavisd-milter (http://amavis.org/) >X-Virus-Scanned: by amavisd-milter (http://amavis.org/) >X-Spam-Status: No, hits=0.6 required=5.0 tests=HTML_30_40 version=2.54 >X-Spam-Level: >X-Spam-Checker-Version: SpamAssassin 2.54 (1.174.2.17-2003-05-11-exp) >Content-Disposition: inline >Content-Transfer-Encoding: 7bit >Subject: [R] Regexpr with "." >X-BeenThere: [EMAIL PROTECTED] >X-Mailman-Version: 2.1.2 >List-Id: Main R Mailing List: Primary help <r-help.stat.math.ethz.ch> >List-Help: <mailto:[EMAIL PROTECTED]> >List-Post: <mailto:[EMAIL PROTECTED]> >List-Subscribe: <https://www.stat.math.ethz.ch/mailman/listinfo/r-help>, <mailto:[EMAIL PROTECTED]> >List-Archive: <https://www.stat.math.ethz.ch/pipermail/r-help> >List-Unsubscribe: <https://www.stat.math.ethz.ch/mailman/listinfo/r-help>, <mailto:[EMAIL PROTECTED]> > >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 Jianhua Zhang Department of Biostatistics Dana-Farber Cancer Institute 44 Binney Street Boston, MA 02115-6084 ______________________________________________ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help