Import decimal coordinates from excel in r

I have an excel file with two columns, like this:

lon         lat
14,1910200  40,8283663
14,1910947  40,8284298
14,1912717  40,8283315
14,1910512  40,8284435
14,1910553  40,8284285

when i try to import it in R with read.xlsx , it truncates the last two decimal places.

      lon      lat 
1  14.19102 40.82837  
2  14.19109 40.82843  
3  14.19127 40.82833  
4  14.19105 40.82844  
5  14.19106 40.82843 

if i use read.xlsx2 it changes lon and lat type to factor and removes decimal zeros.

        lon        lat 
1    14.19102 40.8283663  
2  14.1910947 40.8284298  
3  14.1912717 40.8283315  
4  14.1910512 40.8284435  
5  14.1910553 40.8284285  

There is a function that allows to import all seven decimal digits as numerical type? thanks.


尝试改变你的数字选项,并看看?options

options()$digits
# [1] 7
x <- 1.123456789
x
# [1] 1.123457

options(digits = 10)
x
# [1] 1.123456789
链接地址: http://www.djcxy.com/p/38326.html

上一篇: 单独混合日期和时间

下一篇: 从r中的excel导入小数坐标