Re: [R] exaustive subgrouping or combination

From: Peter Dalgaard <p.dalgaard_at_biostat.ku.dk>
Date: Fri, 29 Jun 2007 23:54:09 +0200

David Duffy wrote:
> On Fri, 29 Jun 2007, Peter Dalgaard wrote:
>
>
>> David Duffy wrote:
>>
>>>> Waverley <waverley.paloalto_at_gmail.com> asked:
>>>>
>>>> Dear Colleagues,
>>>>
>>>> I am looking for a package or previous implemented R to subgroup and
>>>> exaustively divide a vector of squence into 2 groups.
>>>>
>>>> --
>>>> Waverley @ Palo Alto
>>>>
>>>>
>>> Google "[R] Generating all possible partitions" and you will find some R
>>> code
>>> from 2002 or so.
>>>
>>>
>>>
>> In 2002 this wasn't already in R. These days, help(combn) is more to the
>> point:
>>
>> mn <- sort(zapsmall(combn(sleep$extra,10,mean)))
>> plot(unique(mn),table(mn))
>> abline(v=mean(sleep$extra[1:10]))
>>
>>
>
> As I read it, the original query is about partitioning the set eg
> ((1 2) 3) ((1 3) 2) (1 (2 3)).
>
>
Yes, and

 > combn(3,2)

     [,1] [,2] [,3]
[1,] 1 1 2
[2,] 2 3 3

gives you the first group of each of the three partitions



R-help_at_stat.math.ethz.ch 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 Fri 29 Jun 2007 - 22:02:06 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 Fri 29 Jun 2007 - 22:32:40 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.