Re: [R] Doing operations by grouping variable

2010-09-23 Thread ONKELINX, Thierry
- > Van: r-help-boun...@r-project.org > [mailto:r-help-boun...@r-project.org] Namens William Dunlap > Verzonden: woensdag 22 september 2010 19:51 > Aan: Seth W Bigelow; bill.venab...@csiro.au > CC: r-help@r-project.org > Onderwerp: Re: [R] Doing operations by grouping variable >

Re: [R] Doing operations by grouping variable

2010-09-22 Thread Michael Bedward
ge- >> From: r-help-boun...@r-project.org >> [mailto:r-help-boun...@r-project.org] On Behalf Of Seth W Bigelow >> Sent: Tuesday, September 21, 2010 4:22 PM >> To: bill.venab...@csiro.au >> Cc: r-help@r-project.org >> Subject: Re: [R] Doing operations by gro

Re: [R] Doing operations by grouping variable

2010-09-22 Thread William Dunlap
> -Original Message- > From: r-help-boun...@r-project.org > [mailto:r-help-boun...@r-project.org] On Behalf Of Seth W Bigelow > Sent: Tuesday, September 21, 2010 4:22 PM > To: bill.venab...@csiro.au > Cc: r-help@r-project.org > Subject: Re: [R] Doing operations

Re: [R] Doing operations by grouping variable

2010-09-21 Thread Seth W Bigelow
cific Southwest Research Station 1731 Research Park Drive, Davis California 09/21/2010 03:15 PM To cc , Subject RE: [R] Doing operations by grouping variable You left out the subscript. Why not just do d <- within(data.frame(group = rep(1:5, each = 5), variable =

Re: [R] Doing operations by grouping variable

2010-09-21 Thread Bill.Venables
.bedw...@gmail.com; r-help@r-project.org Subject: RE: [R] Doing operations by grouping variable Thanks, Bill and Michael, you have answered the question I asked, but not the one I wished to ask I want to obtain the maximum in each group of variables, so I could scale each variable by the maximu

Re: [R] Doing operations by grouping variable

2010-09-21 Thread Seth W Bigelow
Seth W Bigelow" , "R-help" cc Subject RE: [R] Doing operations by grouping variable Have you tried using ave()? group <- rep(1:5,each=5) variable <- log(1:25) d <- data.frame(group, variable) d$scaled <- d$variable/with(d, ave(variable, group, FUN=max)

Re: [R] Doing operations by grouping variable

2010-09-21 Thread William Dunlap
: r-help-boun...@r-project.org > [mailto:r-help-boun...@r-project.org] On Behalf Of Seth W Bigelow > Sent: Tuesday, September 21, 2010 8:43 AM > To: bill.venab...@csiro.au > Cc: r-help@r-project.org > Subject: Re: [R] Doing operations by grouping variable > > Thanks, Bill and Mi

Re: [R] Doing operations by grouping variable

2010-09-21 Thread Seth W Bigelow
d using attach().) Bill Venables. -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Michael Bedward Sent: Tuesday, 21 September 2010 11:15 AM To: Seth W Bigelow; Rhelp Subject: Re: [R] Doing operations by grouping variable Not sure

Re: [R] Doing operations by grouping variable

2010-09-20 Thread Bill.Venables
ginal Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Michael Bedward Sent: Tuesday, 21 September 2010 11:15 AM To: Seth W Bigelow; Rhelp Subject: Re: [R] Doing operations by grouping variable Not sure why you think tapply is "awkward"

Re: [R] Doing operations by grouping variable

2010-09-20 Thread Michael Bedward
Not sure why you think tapply is "awkward". Your example would be... group <- rep(1:5, each=5) variable <- rnorm(25) tapply(variable, group, max) ...which looks quite elegant to me :) Meanwhile, the reason your expression doesn't work is that you are asking mistakenly for elements 1:5 repeatedly

[R] Doing operations by grouping variable

2010-09-20 Thread Seth W Bigelow
I'm writing an expression that requires searching a vector according to group. As an example, I want to find the maximum value in each of 5 groups. group=rep(1:5, each=5) # create grouping variable variable=rnorm(25) # generate data d <-