[R] Problem with expand.grid() function

Bogaso bogaso.christofer at gmail.com
Tue Mar 30 05:27:51 CEST 2010


Hi, good morning,

I got following error which looks strange to me while executing this code :

> temp <- expand.grid(rep(list(c(1,0)),40))
Error in rep.int(rep.int(seq_len(nx), rep.int(rep.fac, nx)), orep) : 
  invalid 'times' value
In addition: Warning message:
In rep.int(rep.int(seq_len(nx), rep.int(rep.fac, nx)), orep) :
  NAs introduced by coercion


However if I put a small number like 12 in place of 40, it is working fine.
A moderately bigger number than 10 like 30 give a memory related error :

> temp <- expand.grid(rep(list(c(1,0)),20))
Warning messages:
1: Reached total allocation of 1535Mb: see help(memory.size) 
2: Reached total allocation of 1535Mb: see help(memory.size) 
3: In attributes(.Data) <- c(attributes(.Data), attrib) :
  Reached total allocation of 1535Mb: see help(memory.size)
4: In attributes(.Data) <- c(attributes(.Data), attrib) :
  Reached total allocation of 1535Mb: see help(memory.size)

But I badly need to execute this code for a large number like 150 (which I
dont think a big number at all). Is there any other way to do the same task?
Your help will be highly appreciated.

I am working with R-2.10.1 within Vista with a 3gb RAM.

Thanks

-- 
View this message in context: http://n4.nabble.com/Problem-with-expand-grid-function-tp1740345p1740345.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list