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

From: Charles C. Berry <cberry_at_tajo.ucsd.edu>
Date: Thu, 26 Jun 2008 11:50:53 -0700

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' will contain a 1024 row by 10 col dataframe. putting
> it through a transpose, gives you the 10 rows by 1024 cols matrix.
>
> on 06/26/2008 02:18 PM SARAH A DEPAOLI said the following:
>> 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 matrix?
>> Thanks!
>> Sarah Depaoli
>>
>> ______________________________________________
>> R-help_at_r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
> ______________________________________________
> R-help_at_r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>

Charles C. Berry                            (858) 534-2098
                                             Dept of Family/Preventive Medicine
E mailto:cberry_at_tajo.ucsd.edu	            UC San Diego
http://famprevmed.ucsd.edu/faculty/cberry/ La Jolla, San Diego 92093-0901

R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Thu 26 Jun 2008 - 19:23:03 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 26 Jun 2008 - 20:32:48 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive