How can I generate all of the 6 combinations of 2 treatments (A,B) in blocks of 4, such that in each block there is an equal number of A's and B's, using R?
"AABB","ABAB","ABBA","BBAA","BABA","BAAB"
P.S. The number of combinations is calculated as follows:
If
T = #treatments
n = #treatments in each block = k*T,
The number of combinations equals n! / [k!*k! (T times)]
Thank you
The
multicool
package implements an algorithm for permuting multisets --- exactly the task you want to have performed. Here's an example of what it can do:Something like this should work:
The expected solution can also be achieved using the new
iterpc
package.