[R] Error: cannot allocate vector of size xxx Mb

Ralf B ralf.bierig at gmail.com
Thu Aug 5 09:53:21 CEST 2010


I am dealing with very large data frames, artificially created with
the following code, that are combined using rbind.


a <- rnorm(5000000)
b <- rnorm(5000000)
c <- rnorm(5000000)
d <- rnorm(5000000)
first <- data.frame(one=a, two=b, three=c, four=d)
second <- data.frame(one=d, two=c, three=b, four=a)
rbind(first, second)

which results in the following error for each of the statements:

> a <- rnorm(5000000)
Error: cannot allocate vector of size 38.1 Mb
> b <- rnorm(5000000)
Error: cannot allocate vector of size 38.1 Mb
> c <- rnorm(5000000)
Error: cannot allocate vector of size 38.1 Mb
> d <- rnorm(5000000)
Error: cannot allocate vector of size 38.1 Mb
> first <- data.frame(one=a, two=b, three=c, four=d)
Error: cannot allocate vector of size 38.1 Mb
> second <- data.frame(one=d, two=c, three=b, four=a)
Error: cannot allocate vector of size 38.1 Mb
> rbind(first, second)

When running memory.limit() I am getting this:

memory.limit()
[1] 2047

Which shows me that I have 2 GB of memory available. What is wrong?
Shouldn't 38 MB be very feasible?

Best,
Ralf



More information about the R-help mailing list