[R] as.numeric looses precision

Kehl Dániel kehld at ktk.pte.hu
Thu Jul 2 16:06:00 CEST 2015


Hi Roger,

I think it does! Try multiplying with 1000000 or similar. It is just a matter of displaying your result.

best
d
________________________________________
Feladó: R-help [r-help-bounces at r-project.org] ; meghatalmazó: Bos, Roger [roger.bos at rothschild.com]
Küldve: 2015. július 2. 15:54
To: r-help at r-project.org
Tárgy: [R] as.numeric looses precision

I have a string that contains a number and when I convert it to a number I loose precision and I would like to know if there is a way to avoid that.  Here is my example:

p <- "1087.003489"
as.numeric(p, digits=6)

R gives me 1087.003:

> p <- "1087.003489"
> as.numeric(p, digits=6)
[1] 1087.003

I would be nice if I could keep all the decimal places after the conversion.

Thanks,

Roger





***************************************************************
This message and any attachments are for the intended recipient's use only.
This message may contain confidential, proprietary or legally privileged
information. No right to confidential or privileged treatment
of this message is waived or lost by an error in transmission.
If you have received this message in error, please immediately
notify the sender by e-mail, delete the message, any attachments and all
copies from your system and destroy any hard copies.  You must
not, directly or indirectly, use, disclose, distribute,
print or copy any part of this message or any attachments if you are not
the intended recipient.

______________________________________________
R-help at r-project.org 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.



More information about the R-help mailing list