[R] as.numeric looses precision

Bos, Roger roger.bos at rothschild.com
Thu Jul 2 15:54:46 CEST 2015


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.



More information about the R-help mailing list