问题
I have a weblink to get some test data which is in the form of a .csv file (European). I've tried using the following command:
dat <- fread(file_link, sep = ";", dec = ",")
Where file_link
is the weblink - since it can not be accessed from outside the private network, here is a sample https://drive.google.com/file/d/0BwghuckSBss7ZmtEMXBYMGNSOWs/view?usp=sharing
The data.tables shows the different observations as 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>
I have seen the question posted here (decimal point setting in fread, data.table) but it doesn't appear to be working in my case. Some additional details:
> 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
来源:https://stackoverflow.com/questions/46637238/fread-ignores-sep-and-dec-when-reading-from-weblink