Reputation: 11155
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.
Upvotes: 1
Views: 1273
Reputation: 11155
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:
plot(as.POSIXlt(mydata$Date, format="%m/%d/%Y %H:%M:%S %p"), mydata$Price)
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.
Upvotes: 2