On Mon, Jun 13, 2011 at 8:48 AM, Lee, Eric <e...@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.
You could use gsub. if you have a character string s, use sWithoutCommas = gsub(",", "", s, fixed = TRUE) to remove all commas from s. To do it for a whole table, I would do something like removeComma= function(s) {gsub(",", "", s, fixed = TRUE)} tabWithoutCommas = apply(tab, 2, removeComma) Try it to see if does what you need. HTH, Peter ______________________________________________ R-help@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.