我正在将一个大型 .csv 文件导入到 R 中(大约 50 万行),因此我一直在尝试使用 data.table 包中的 fread() 作为 read.table() 和 read.csv( )。然而,fread() 返回一个数据帧,其中包含一行内各行的所有数据,即使它具有正确的列数。我发现 2013 年的错误报告显示这与 integer64 数据类相关:
有没有解决办法或方法来解决这个问题?
我尝试读取的 .csv 文件完全是 0 - 10000 范围内的整数,没有丢失数据。我在 Windows 7 计算机上使用 R 版本 2.15.2,以及 data.table 包版本 1.8.8。
我正在运行的代码是:
require(data.table)
fread("pre2012_alldatapoints.csv", sep = ",", header= TRUE)-> pre
head(pre)
1: 1 22 -105 22 -105
2: 2 22 -105 22 -105
3: 3 20 -105 20 -105
4: 4 21 -105 21 -105
5: 5 21 -105 21 -105
6: 6 21 -105 21 -105
dim(pre)
[1] 12299 5 #dim returns the correct number of dimensions
#this is a subset of the file I want to import that I've confirmed imports correctly with read.csv
pre[,1]
[1] 1 #but trying to print a column returns this
length(pre[,1])
[1] 1 #and length for any column returns a row length of 1
fread
创建一个data.table
. The data.table
包装内附有许多小插图;请访问网站了解更多信息:https://rdatatable.gitlab.io/data.table/ https://rdatatable.gitlab.io/data.table/
实际上自从这个问题发布以来,data.table
已经改变了pre[ , 1]
现在按原来的预期工作。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)