Wired result when I convert from Character to Numeric

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Wired result when I convert from Character to Numeric

Bogaso
Hi,

Below is my simple result in R

> x = "1282553.8210000000"
> as.numeric(x)
[1] 1282554

Any idea where all numbers in the decimal places (ie 8, 2, 1) are gone?

Thanks,

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
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.
Reply | Threaded
Open this post in threaded view
|

Re: Wired result when I convert from Character to Numeric

Gerrit Eichner
Hi, Christofer,

try

print(as.numeric(x), digits = 10) # or another number of digits

to increase the printed(!) precision.

  Hth  --  Gerrit

Am 23.05.2018 um 12:42 schrieb Christofer Bogaso:

> Hi,
>
> Below is my simple result in R
>
>> x = "1282553.8210000000"
>> as.numeric(x)
> [1] 1282554
>
> Any idea where all numbers in the decimal places (ie 8, 2, 1) are gone?
>
> Thanks,
>
> ______________________________________________
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> 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.
>

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
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.