help.search("subset") on my R installation gives:
nchoosek(vsn) List all subsets of size k from n objects
and "vsn" is one of the Bioconductor packages. From that, the
index.subsets() you want shouldn't be too hard to construct...
HTH,
Andy
> -----Original Message-----
> From: Spencer Graves [mailto:spencer.graves at pdf.com]
> Sent: Friday, August 01, 2003 6:56 AM
> To: R-help
> Subject: [R] index all subsets of k of m items?
>
>
> How can I efficiently index all choose(m, k) subsets
> of m items taken
> k at a time? For example, with (m, k) = (3, 2), the subsets
> are (1, 2),
> (1, 3), and (2, 3). I'd like a function something like
> "index.subsets(subset, k, m)" that would return 1, 2 or 3 for
these 3
> subsets. Examples:
>
> index.subsets(c(1,2), 2, 3) -> 1
> index.subsets(c(1,3), 2, 3) -> 2
> index.subsets(c(2,3), 2, 3) -> 3
>
> index.subsets(c(1,2,3), 3, 5) -> 1
> index.subsets(c(1,2,5), 3, 5) -> 3
> index.subsets(c(3,4,5), 3, 5) -> 10
>
> Thanks.
> Spencer Graves
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo> /r-help
>
------------------------------------------------------------------------------
Notice: This e-mail message, together with any attachments, contains
information of Merck & Co., Inc. (Whitehouse Station, New Jersey, USA),
and/or
its affiliates (which may be known outside the United States as Merck Frosst,
Merck Sharp & Dohme or MSD) that may be confidential, proprietary
copyrighted
and/or legally privileged, and is intended solely for the use of the
individual or entity named on this message. If you are not the intended
recipient, and have received this message in error, please immediately return
this by e-mail and then delete it.