我有一个网络链接来获取一些.csv文件(欧洲)形式的测试数据。我尝试过使用以下命令:
dat <- fread(file_link, sep = ";", dec = ",")
其中file_link
是网络链接 - 因为无法从专用网络外部访问,所以这里有一个示例https://drive.google.com/file/d/0BwghuckSBss7ZmtEMXBYMGNSOWs/view?usp=sharing
data.tables将不同的观察结果显示为chr
:
> str(dat)
Classes ‘data.table’ and 'data.frame': 377 obs. of 7 variables:
$ tme : chr "2017-10-01 21:00:00" "2017-10-01 21:01:00" "2017-10-01 21:02:01" "2017-10-01 21:03:00" ...
$ degc : chr "24,95" "24,95" "24,99" "24,99" ...
$ rh : chr "27,005" "27,005" "26,903" "26,903" ...
$ pres : int 100775 100775 100778 100778 100766 100766 100769 100769 100768 100768 ...
$ pm1 : chr "892,87" "886,565" "874,689" "876,735" ...
$ pm2.5: chr "1761,31" "1744,13" "1720,47" "1724,42" ...
$ pm10 : chr "1994,24" "1974,4" "1935,62" "1944,31" ...
- attr(*, ".internal.selfref")=<externalptr>
我在这里发布了一个问题(decimal point setting in fread, data.table),但它似乎并没有在我的案例中发挥作用。一些额外的细节:
> options()$datatable.fread.dec.locale
[1] "fr_FR.utf8"
> sessionInfo()
R version 3.3.3 (2017-03-06)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: macOS Sierra 10.12.6
locale:
[1] en_CA.UTF-8/en_CA.UTF-8/en_CA.UTF-8/C/en_CA.UTF-8/en_CA.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] rio_0.5.5 reshape2_1.4.2 lubridate_1.6.0 stringr_1.2.0 ggplot2_2.2.1
[6] data.table_1.10.4 dplyr_0.7.4
loaded via a namespace (and not attached):
[1] Rcpp_0.12.13 bindr_0.1 magrittr_1.5 munsell_0.4.3 colorspace_1.3-2
[6] R6_2.2.2 rlang_0.1.2 plyr_1.8.4 tools_3.3.3 grid_3.3.3
[11] gtable_0.2.0 readxl_1.0.0 lazyeval_0.2.0 assertthat_0.2.0 tibble_1.3.4
[16] bindrcpp_0.2 curl_3.0 glue_1.1.1 haven_1.1.0 labeling_0.3
[21] openxlsx_4.0.17 stringi_1.1.5 cellranger_1.1.0 forcats_0.2.0 scales_0.5.0
[26] foreign_0.8-69 pkgconfig_2.0.1