Re: [R] function for grouping

2012-01-26 Thread Petr Savicky
On Thu, Jan 26, 2012 at 08:29:22AM -0800, yan wrote: > what if I don't need to store the combination results, I just want to get the > combination result for a given row. > e.g. for the 5 elements divided into 3 groups , and if I give another > parameter which is the row number of the results, in p

Re: [R] function for grouping

2012-01-26 Thread Petr Savicky
On Thu, Jan 26, 2012 at 08:29:22AM -0800, yan wrote: > what if I don't need to store the combination results, I just want to get the > combination result for a given row. > e.g. for the 5 elements divided into 3 groups , and if I give another > parameter which is the row number of the results, in p

Re: [R] function for grouping

2012-01-26 Thread yan
what if I don't need to store the combination results, I just want to get the combination result for a given row. e.g. for the 5 elements divided into 3 groups , and if I give another parameter which is the row number of the results, in petr's example, say if I set row number to 1, then I get 1,2,3

Re: [R] function for grouping

2012-01-25 Thread Greg Snow
Of David Winsemius > Sent: Wednesday, January 25, 2012 10:23 AM > To: yan > Cc: r-help@r-project.org > Subject: Re: [R] function for grouping > > > On Jan 25, 2012, at 12:10 PM, yan wrote: > > > thanks petr, > > what if I got 200 elements, so I have to write exp

Re: [R] function for grouping

2012-01-25 Thread Petr Savicky
On Wed, Jan 25, 2012 at 09:10:13AM -0800, yan wrote: > thanks petr, > what if I got 200 elements, so I have to write expand.grid(x1=1, x2=1:2, > x3=1:3, x4=1:3, x5=1:3x200=1:3))? Hi. As others told you, the problem is not in reformulating the command in a concise way, but in enormous memory a

Re: [R] function for grouping

2012-01-25 Thread Jorge I Velez
No, you have not. Take a look at expand.grid(rep(list(1:5), 2)) HTH, Jorge.- On Wed, Jan 25, 2012 at 12:10 PM, yan <> wrote: > thanks petr, > what if I got 200 elements, so I have to write expand.grid(x1=1, x2=1:2, > x3=1:3, x4=1:3, x5=1:3x200=1:3))? > > Many thanks > > yan > > -- > View

Re: [R] function for grouping

2012-01-25 Thread Jeff Newmiller
You will run out of memory. 2*3^198 is about 5e95 rows and 4GB of RAM can probably only hold about 5e8 rows. --- Jeff NewmillerThe . . Go Live... DCN:Basics: ##.#. ##.#.

Re: [R] function for grouping

2012-01-25 Thread David Winsemius
On Jan 25, 2012, at 12:10 PM, yan wrote: thanks petr, what if I got 200 elements, so I have to write expand.grid(x1=1, x2=1:2, x3=1:3, x4=1:3, x5=1:3x200=1:3))? Perhaps same thing that will happen when those monks finish the Towers of Hanoi? 2*3^198 [1] 5.902533e+94 -- David Wins

Re: [R] function for grouping

2012-01-25 Thread yan
thanks petr, what if I got 200 elements, so I have to write expand.grid(x1=1, x2=1:2, x3=1:3, x4=1:3, x5=1:3x200=1:3))? Many thanks yan -- View this message in context: http://r.789695.n4.nabble.com/function-for-grouping-tp4324436p4327812.html Sent from the R help mailing list archive at Na

Re: [R] function for grouping

2012-01-24 Thread Petr Savicky
On Tue, Jan 24, 2012 at 07:05:37PM +0100, Petr Savicky wrote: > On Tue, Jan 24, 2012 at 05:19:42PM +, yan jiao wrote: > > Dear All, > > > > I'm wondering if there is a R function could give me all the > > combinations of the grouping/cluster result, given the number of the groups. > > e.g. >

Re: [R] function for grouping

2012-01-24 Thread Petr Savicky
On Tue, Jan 24, 2012 at 05:19:42PM +, yan jiao wrote: > Dear All, > > I'm wondering if there is a R function could give me all the > combinations of the grouping/cluster result, given the number of the groups. > e.g. > 3 objects: x1 x2 x3, number of groups is 2 > so the result will be > group

[R] function for grouping

2012-01-24 Thread yan jiao
Dear All, I'm wondering if there is a R function could give me all the combinations of the grouping/cluster result, given the number of the groups. e.g. 3 objects: x1 x2 x3, number of groups is 2 so the result will be group1:x1,x2; group2: x3 group1: x1;group2: x2,x3 group1: x1,x3;group2: x2 m