1
我正在使用xts並在循環中加載100到1000個文件。每個文件在50k到300k行之間。我在Windows 7 64位上使用R 2.15.1的最新版本。我在使用R版本2.14.X的Ubuntu Linux上遇到同樣的問題。xts :: to.period導致R崩潰的問題
下面的代碼將定期崩潰R:
library(xts)
N <- 1e6
for(i in 1:1000) {
allTimes <- Sys.time()-N:1
x <- NULL
x <- xts(,allTimes)
sampTimes <- allTimes[seq(1,length(allTimes),by=2)]
y <- merge(xts(seq_along(sampTimes), sampTimes), allTimes)
y <- na.locf(y)
y <- to.period(y, 'seconds', 10)
index(y) <- index(to.period(x, 'seconds', 10))
}
這聽起來像你內存不足。你說你在Ubuntu上試過這個,但是你沒有說崩潰是否發生。你的Ubuntu機器上有交換空間嗎? – 2012-07-22 00:39:01
小心分享您使用的代碼?您可以嘗試使用瀏覽器()進行調試。這樣,你「進入」功能,並開始探索。其樂無窮。 – 2012-07-22 07:25:53
一些事情。看來R不喜歡使用打印和閱讀文件。使用進度條有助於R的行爲。 R Studio仍然有問題。適用於Linux和Windows。 – Dave 2012-07-22 18:34:27