[R] as.numeric rounds up

Henrique Dallazuanna
Fri, 01 Feb 2008 18:27:00 -0000

options(digits=10)

> b

or just

print(b, 10)

On 01/02/2008, Monica Pisica <pisicandru at hotmail.com>
wrote:
>
>
> 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.
>


--
Henrique Dallazuanna
Curitiba-Paran?-Brasil
25? 25' 40" S 49? 16' 22" O