[R] as.numeric rounds up

From: Monica Pisica <pisicandru_at_hotmail.com>
Date: Fri, 1 Feb 2008 18:04:46 +0000

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]]


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. Received on Fri 01 Feb 2008 - 18:15:02 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 01 Feb 2008 - 19:30:10 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive