I have a comma delimited text file in which many columns of numbers are
also quoted and have commas as well as decimals. I was surprised to find
read.csv() didn't import this seamlessly, even after messing around with
the colClasses argument. I did find a solution to convert the character
strings after reading them in, but wonder if there isn't a better one I
overlooked.
test = c("10,522.5","11,768.9","11,354.3")
as.numeric(test) # fails
as.numeric(gsub(",","",test)) # works
Any suggestions? Or is this as good as it gets? I'm not complaining ...
just curious!
Drew Tyre
School of Natural Resources
University of Nebraska-Lincoln
416 Hardin Hall, East Campus
Lincoln, NE 68583-0974
phone: +1 402 472 4054 fax: +1 402 472 2946
email: [EMAIL PROTECTED]
http://snr.unl.edu/tyre
[[alternative HTML version deleted]]
______________________________________________
[email protected] 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.