0

I have a data.frame where I need to convert latitudeE7 and longitudeE7 to decimals.

I found a few methods that are very effective.

But it does not show all the numbers.

DF <- data.frame(timestampMs=c("1546585987278","1546585866293","1546585847084","1546585738420","1546585613737","1546585493169"),
                 latitudeE7=c(356273747,356273747,356315165,
                              356585848,357100674,357038755),                                                                
                 longitudeE7=c(1398768447,1398768447,1398779562,
                               1397432442,1398085117,1398109875))

I used these two methods

DF$lat = DF$latitudeE7 / 10000000
DF$lon = DF$longitudeE7 / 1e7

I got this

       timestampMs   latitudeE7   longitudeE7      lat       lon
 1   1546585987278    356273747    1398768447   35.62737   139.8768
 2   1546585866293    356273747    1398768447   35.62737   139.8768
 3   1546585847084    356315165    1398779562   35.63152   139.8780
 4   1546585738420    356585848    1397432442   35.65858   139.7432
 5   1546585613737    357100674    1398085117   35.71007   139.8085
 6   1546585493169    357038755    1398109875   35.70388   139.8110

You can see that the numbers behind lat and lon are not all displayed.

Even if I use round (DF$latitudeE7 / 10000000, digits=7), it still has the same result.

I hope to get such a result. Is there a problem with it?

       timestampMs   latitudeE7   longitudeE7       lat            lon
 1   1546585987278    356273747    1398768447   35.6273747   139.8768447
 2   1546585866293    356273747    1398768447   35.6273747   139.8768447
 3   1546585847084    356315165    1398779562   35.6315165   139.8779562
 4   1546585738420    356585848    1397432442   35.6585848   139.7432442
 5   1546585613737    357100674    1398085117   35.7100674   139.8085117
 6   1546585493169    357038755    1398109875   35.7038755   139.8109875
Konrad Rudolph
  • 530,221
  • 131
  • 937
  • 1,214
kolinunlt
  • 349
  • 1
  • 11

2 Answers2

2

The numbers are stored correctly, they just aren't visible. Change the global options for digits if you want to see more:

options(digits = 10)

#### OUTPUT ####

    timestampMs latitudeE7 longitudeE7        lat         lon
1 1546585987278  356273747  1398768447 35.6273747 139.8768447
2 1546585866293  356273747  1398768447 35.6273747 139.8768447
3 1546585847084  356315165  1398779562 35.6315165 139.8779562
4 1546585738420  356585848  1397432442 35.6585848 139.7432442
5 1546585613737  357100674  1398085117 35.7100674 139.8085117
6 1546585493169  357038755  1398109875 35.7038755 139.8109875
0

I don't think there is any problem here, it's just that this is printed this way, but R internally stores those digits.

If you want to be sure of this, you can try :

format(DF$lat[1], digits=7)

and check that you have all the 7 digits.

fmarm
  • 4,209
  • 1
  • 17
  • 29