[R] Expanding upon expand.grid()

About this list Date view Thread view Subject view Author view Attachment view

From: Andrew Criswell (arc@arcriswell.com)
Date: Thu 08 May 2003 - 12:38:48 EST


Message-id: <002a01c3150a$f6efe900$0ed994cb@andrewhdh0e5oe>

Hello All:

The function expand.grid() does nearly exactly what I want for
permutation tests I wish to carry out, and it does so quickly when the
number is kept small as in the example below:

expand.grid(rep(list(c(-1, 1)), 3))

  Var1 Var2 Var3
1 -1 -1 -1
2 1 -1 -1
3 -1 1 -1
4 1 1 -1
5 -1 -1 1
6 1 -1 1
7 -1 1 1
8 1 1 1

Understandably, for a larger number--16, for example--the grid expands
to a 65,536 x 16 = 1,048,576 element array of numbers.

My question is this: is it possible to compute a grid like the one above
on a row-by-row basis? What I would like to do is to iteratively take
one row at a time, compute its sum, store the computed sum for the row,
and replace the latest row by the next row. In that way, memory burden
and computation time would be reduced.

Thanks for your help,
ANDREW

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


About this list Date view Thread view Subject view Author view Attachment view

This archive was generated by hypermail 2.1.3 : Tue 01 Jul 2003 - 09:11:45 EST