Preserving large numbers

后端 未结 8 1758
一生所求
一生所求 2020-12-01 18:30

I am trying to read a CSV file that has barcodes in the first column, but when R gets it into a data.frame, it converts 1665535004661 to 1.67E+12.<

8条回答
  •  执笔经年
    2020-12-01 19:10

    It's not in a "1.67E+12 format", it just won't print entirely using the defaults. R is reading it in just fine and the whole number is there.

    x <- 1665535004661
    > x
    [1] 1.665535e+12
    > print(x, digits = 16)
    [1] 1665535004661
    

    See, the numbers were there all along. They don't get lost unless you have a really large number of digits. Sorting on what you brought in will work fine and you can just explicitly call print() with the digits option to see your data.frame instead of implicitly by typing the name.

提交回复
热议问题