[R] remove commas in a number when reading a text file
Joshua Wiley
jwiley.psych at gmail.com
Mon Jun 13 22:34:10 CEST 2011
Hi Eric,
Try this:
gsub(",", "", "1,234,567", fixed = TRUE)
Cheers,
Josh
On Mon, Jun 13, 2011 at 8:48 AM, Lee, Eric <elee at air-worldwide.com> wrote:
> Hello,
>
> I'm running version R x64 v2.12.2 on a 64bit windows 7 PC. I'm trying to read a text file using read.table where the values have a format like "1,234,567". What I want is "1234567". Is there a quick way to strip out the commas? I can use strsplit and paste, but the file is quite large and would take some time. Thanks.
>
> Eric
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
--
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
http://www.joshuawiley.com/
More information about the R-help
mailing list