0

How do I retain the full 16 digit precision when coercing a text to numeric in R? My attempt below does not appear to do this...

x<-"0.501288104715059"
x<-as.double(x)
x
[1] 0.5012881

[Note this is similar to a previously asked question using as.numeric to convert a character to number but his question refers to the case of using as.double to convert a character to a number]

Markm0705
  • 1,340
  • 1
  • 13
  • 31

1 Answers1

2

The code in fact does work - I just needed to set the number of digits to be displayed

x<-"0.501288104715059"
x<-as.double(x)
options(digits=16)
x
[1] 0.501288104715059

Might be useful to somebody else

Markm0705
  • 1,340
  • 1
  • 13
  • 31
  • 1
    Duplicate of [Controlling number of decimal digits in print output in R](https://stackoverflow.com/questions/2287616/controlling-number-of-decimal-digits-in-print-output-in-r). Please search SO for your issue before posting duplicates. – smci Jun 28 '15 at 01:37