-
> 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
>
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
> -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
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 =
Park Drive, Davis California
09/20/2010 06:24 PM
To
, ,
cc
Subject
RE: [R] Doing operations by grouping variable
That's if the variables are visible. If they are only in the data frame it's
not much more difficult
d <- data.frame(group
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)
: 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
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
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"
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
10 matches
Mail list logo