我試圖將一個大的(〜700Mb).csv文件讀入R.R是否支持8位變量?
該文件包含一個小於256的整數數組,其中包含一個標題行和2個標題列。
我用:
trainSet <- read.csv(trainFileName)
這最終barfs有:
Loading Data...
R(2760) malloc: *** mmap(size=151552) failed (error code=12)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug
R(2760) malloc: *** mmap(size=151552) failed (error code=12)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug
Error: cannot allocate vector of size 145 Kb
Execution halted
綜觀內存使用,它在6GB的機器上有關的3Gb使用與在零頁面文件使用conks出事故發生的時間,所以可能有另一種解決方法。
如果我使用:
trainSet <- read.csv(trainFileName, header=TRUE, nrows=100)
classes = sapply(train,class);
我可以看到,所有的列被加載爲「整數」我認爲這是32位。
很明顯,使用3Gb加載700Mb .csv文件的一部分遠沒有效率。我想知道是否有辦法告訴R使用8位數字作爲列?這是我在過去在Matlab中完成的工作,然而,我似乎無法在R中找到任何提及的8位類型的地方。
它存在嗎?我怎麼會告訴它read.csv使用它?
在此先感謝您的幫助。
可能的解決方案:A)得到更多的內存b)將數據存入數據庫,併爲使用'RMySQL'需要讀取數據塊。 c)快速啓動一個大內存的EC2實例並在那裏運行。 – Maiasaura
@Maiasaura:或只是注意文檔中的警告。 ;-) –