... and actually, since u can be assumed to be of the form shown,
v <-do.call(expand.grid, split(rep(u,len),rep(u,e=len)))
should do.
-- Bert
On Thu, Nov 7, 2013 at 10:06 AM, Bert Gunter wrote:
> Well, you can create the expand.grid data frame programmatically via:
>
> u <- 1:3
> len <- lengt
Well, you can create the expand.grid data frame programmatically via:
u <- 1:3
len <- length(u)
v <-do.call(expand.grid, split(rep(u,len),rep(seq_len(len),e=len)))
And then you can use unique.array to get the unique rows after the sort:
unique(t(apply(v,1,sort)))
However, I agree with your sent
On 07-Nov-2013 13:38:29 Konstantin Tretiakov wrote:
> Hello!
>
> I need to obtain all possible combinations with replacement when
> order is not important.
> E.g. I have a population x{1,2,3}.
> So I can get (choose(3+3-1,3)=) 10 combinations from this population
> with 'size=3'.
> How can I get a
retiakov
> Sent: Thursday, November 07, 2013 5:38 AM
> To: r-help@r-project.org
> Subject: [R] all combinations with replacement not ordered
>
> Hello!
>
> I need to obtain all possible combinations with replacement when order is
> not important.
> E.g. I have a populatio
Hello!
I need to obtain all possible combinations with replacement when order is
not important.
E.g. I have a population x{1,2,3}.
So I can get (choose(3+3-1,3)=) 10 combinations from this population with
'size=3'.
How can I get a list of all that combinations?
I have tried 'expand.grid()' and ma
5 matches
Mail list logo