[R] as.numeric rounds up

Monica Pisica pisicandru at hotmail.com
Fri Feb 1 19:04:46 CET 2008



Hi list,

It seems that as.numeric is rounding up my numbers that are in a character format.

Example:

a
[1] "776554.45" "776985.31" "776076.03" "776092.01" "776151.42" "776276.97"


b <- as.numeric(a)
b
[1] 776554.4 776985.3 776076.0 776092.0 776151.4 776277.0



I've tried as.numeric(a,2) and as.numeric(a, digits = 2) but it didn't work, nor  ? as.numeric gave me any clues. How can i transform my character numbers in numeric without loosing the decimal digits?

Thanks,

Monica


_________________________________________________________________
[[elided Hotmail spam]]



More information about the R-help mailing list