我试着用vroom读取一些空格分隔的数据,大约一年前,这个方法可以给出11列数字数据:
library(vroom)
fname <- "http://berkeleyearth.lbl.gov/auto/Global/Complete_TAVG_complete.txt"
dat <- vroom(file = fname, delim = " ", col_names = FALSE, comment = "%", na = "NaN")
现在我在dat
中得到了58列,大部分是空逻辑,这是白色的编码问题吗?
下面是sessionInfo()
:
R version 4.2.2 (2022-10-31)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Big Sur 11.7.4
Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.2/Resources/lib/libRlapack.dylib
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] vroom_1.6.1
1条答案
按热度按时间p5cysglq1#
它看起来像一个固定宽度的文件,所以分隔符不起作用。使用
vroom::vroom_fwf()
。