R 仅消耗约 200MB 后就耗尽内存
我有以下脚本:
mydata <- read.csv(file="priceData.txt", head=TRUE, sep='\t')
plot(mydata$Date, mydata$Price)
mydata$Date 和 $Price 的长度为 98385。它似乎可以很好地读取数据,我可以毫无问题地对其进行计算。我可以根据该数据构建新的向量,但无法针对它进行绘图。
如果我尝试,我会收到以下错误:
错误:无法分配大小为 8.1 Gb 的向量 另外:警告消息:
1:在rep.int(boxwex,n)中:
总分配达到 6135Mb:请参阅帮助(内存.大小)
这是假的。发生崩溃时平均使用约 170MB。我在 64 位 Win7 上运行 Rgui 和 R-2.12.2。任务管理器报告的整个系统的总内存使用量约为 2GB(我有 6GB)。
我不明白我怎么会内存不足。
I have the following script:
mydata <- read.csv(file="priceData.txt", head=TRUE, sep='\t')
plot(mydata$Date, mydata$Price)
mydata$Date and $Price are of length 98385. It seems to read the data fine, I can do computations on it no problem. I can build new vectors based on that data, but I can't plot against it.
If I try, I receive the following error:
Error: cannot allocate vector of size 8.1 Gb
In addition: Warning messages:
1: In rep.int(boxwex, n) :
Reached total allocation of 6135Mb: see help(memory.size)
This is bogus. It is using ~170MB on average when the crash occurs. I'm running Rgui with R-2.12.2 on 64bit Win7. And the total memory usage as reported by Task Manager is ~2GB for the whole system (out of 6GB I have).
I don't understand how I can be running out of memory.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,内存不足错误显然与任何事情都没有关系。只是 CSV 解析器无法将日期列值识别为日期和时间的组合。需要额外的强制。感谢我的问题+谷歌回复中的建议,我找到了适合这项工作的功能。下面的代码按照我想要的方式工作:
我有点明白它并不真正知道我可能想要从 CSV 列中得到什么,但内存不足错误似乎是对此的完全错误的反应。
Alright, the Out Of Memory error has nothing to do with anything apparently. It just that CSV parser does not recognize Date column values as Date and Time combined. Needs extra coercing. Thanks to the suggestions in the replies to my question + google I found the right function for the job. The following code works as I wanted it to:
I sort of understand that it doesn't really know what I might want from a CSV column, but Out Of Memory error just seems like the exactly the wrong reaction to this.