Re: [R] Data matrix of all possible response patterns

2008-06-26 Thread Charles C. Berry
mat <- outer( 0:9, 0:(1024-1), function(x,y) y %/% (2^x) %% 2 ) On Thu, 26 Jun 2008, Daniel Folkinshteyn wrote: this is probably a cludge, and there may be a "neater" way to do this, but... here's one: a = 0:1 for (i in 1:9){ a= merge(unname(a), 0:1) } a = t(a) after the for loop, 'a'

Re: [R] Data matrix of all possible response patterns

2008-06-26 Thread Henrique Dallazuanna
Try this also: t(expand.grid(rep(list(0:1), 10))) On Thu, Jun 26, 2008 at 3:18 PM, SARAH A DEPAOLI <[EMAIL PROTECTED]> wrote: > I am looking for a way to generate a data matrix that contains all possible > response patterns for 10 binary items. This should produce a matrix with 10 > rows (repre

Re: [R] Data matrix of all possible response patterns

2008-06-26 Thread Daniel Folkinshteyn
this is probably a cludge, and there may be a "neater" way to do this, but... here's one: > a = 0:1 > for (i in 1:9){ a= merge(unname(a), 0:1) } > a = t(a) after the for loop, 'a' will contain a 1024 row by 10 col dataframe. putting it through a transpose, gives you the 10 rows by 1024 cols ma

[R] Data matrix of all possible response patterns

2008-06-26 Thread SARAH A DEPAOLI
I am looking for a way to generate a data matrix that contains all possible response patterns for 10 binary items. This should produce a matrix with 10 rows (representing 10 items) and 1024 columns (representing 2^10 possible response patterns). Does anyone know of code that would produce such a