[R] memory.size help

Michael Dewey info at aghmed.fsnet.co.uk
Sat Sep 1 12:36:44 CEST 2007


At 13:27 31/08/2007, dxc13 wrote:

>I keep getting the 'memory.size' error message when I run a program I have
>been writing.  It always it cannot allocate a vector of a certain size.  I
>believe the error comes in the code fragement below where I have multiple
>arrays that could be taking up space.  Does anyone know a good way around
>this?

It is a bit hard without knowing the dimensions of the arrays but see below.

>w1 <- outer(xk$xk1, data[,x1], function(y,z) abs(z-y))
>w2 <- outer(xk$xk2, data[,x2], function(y,z) abs(z-y))
>w1[w1 > d1] <- NA
>w2[w2 > d2] <- NA
>i1 <- ifelse(!is.na(w1),yvals[col(w1)],NA)
>i2 <- ifelse(!is.na(w2),yvals[col(w2)],NA)

If I read this correctly after this point you no longer need w1 and 
w2 so what happens if you remove them?

>zk <- numeric(nrow(xk))      #DEFININING AN EMPTY VECTOR TO HOLD ZK VALUES
>for(x in 1:nrow(xk)) {
>         k <- intersect(i1[x,], i2[x,])
>         zk[x] <- mean(unlist(k), na.rm = TRUE)
>}
>xk$zk <- zk
>data <- na.omit(xk)
>--
>View this message in context: 
>http://www.nabble.com/memory.size-help-tf4359846.html#a12425401
>Sent from the R help mailing list archive at Nabble.com.

Michael Dewey
http://www.aghmed.fsnet.co.uk



More information about the R-help mailing list