[R] expand.grip for permutations

R. Michael Weylandt michael.weylandt at gmail.com
Wed Oct 31 22:19:45 CET 2012


On Wed, Oct 31, 2012 at 8:18 PM, trekvana <trekvana at aol.com> wrote:
> if i were to have a block size of 4 people and i want to assign a treatment
> combination to the entire block, there would be 16 different treatment
> combinations (TTTT, TTTP, TTPP, PTTP, etc.)
>
> i am trying to get all 16 permutations and i am able to use this code below.
>
> drugs=c('P','T');
> comb=expand.grid(drugs,drugs,drugs,drugs)

do.call(expand.grid, rep(list(drugs),n))

where n is 3,4,5...

Cheers,
Michael

>
> --
> View this message in context: http://r.789695.n4.nabble.com/expand-grip-for-permutations-tp4648067.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> 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.




More information about the R-help mailing list