0

我正在使用 RevoR entreprise 来处理导入大型数据文件。文档中给出的示例指出,将使用 rxImport 循环将 10 个文件(每个 1000000 行)作为数据集导入,如下所示:

setwd("C:/Users/Fsociety/Bigdatasamples")
Data.Directory <- "C:/Users/Fsociety/Bigdatasamples"
Data.File <- file.path(Data.Directory,"mortDefault")
mortXdfFileName <- "mortDefault.xdf"

append <- "none"
for(i in 2000:2009){
importFile <- paste(Data.File,i,".csv",sep="")
mortxdf <- rxImport(importFile, mortXdfFileName, append = append, overwrite = TRUE, maxRowsByCols = NULL)
append <- "rows"    
}
mortxdfData <- RxXdfData(mortXdfFileName)
knime.out <- rxXdfToDataFrame(mortxdfData)

这里的问题是我在数据集中只得到 500000 行,因为maxRowsByCols参数默认是1e+06我将其更改为更高的值,然后更改为,NULL但它仍然会截断文件中的数据。

4

2 回答 2

1

已修复,问题是 RxXdfData() 具有 maxrowbycols 限制,将其更改为 NULL 会将整个 rxXdfData 转换为 Knime 的 data.frame 对象。

于 2016-03-18T15:45:07.453 回答
1

XDF由于您要导入到maxRowsByCols没关系。此外,在您读入 a 的最后一行data.frame,这首先违背了使用 an 的目的XDF

这段代码确实适用于我的数据http://packages.revolutionanalytics.com/datasets/mortDefault.zip,这是我假设你正在使用的。

500K 行是由rowsPerRead参数引起的,但这只是决定块大小。所有数据都以 500k 增量读入,但可以根据您的需要进行更改。

setwd("C:/Users/Fsociety/Bigdatasamples")
Data.Directory <- "C:/Users/Fsociety/Bigdatasamples"
Data.File <- file.path(Data.Directory, "mortDefault")
mortXdfFileName <- "mortDefault.xdf"

append <- "none"
overwrite <- TRUE
for(i in 2000:2009){
  importFile <- paste(Data.File, i, ".csv", sep="")
  rxImport(importFile, mortXdfFileName, append=append, overwrite = TRUE)
  append <- "rows"
  overwrite <- FALSE
}

rxGetInfo(mortxdfData, getBlockSizes = TRUE)

# File name: C:\Users\dnorton\OneDrive\R\MarchMadness2016\mortDefault.xdf 
# Number of observations: 1e+07 
# Number of variables: 6 
# Number of blocks: 20 
# Rows per block (first 10): 5e+05 5e+05 5e+05 5e+05 5e+05 5e+05 5e+05 5e+05 5e+05 5e+05
# Compression type: zlib 
于 2016-03-17T19:56:56.797 回答