Re: [R] tapply within a data.frame: a simpler alternative?

2008-12-11 Thread David Freedman
You might take a look at the transformBy function in the doBy package For example, new.df=transformBy(~group,data=my.df, new=y/max(y)) David Freedman baptiste auguie-2 wrote: Dear list, I have a data.frame with x, y values and a 3-level factor group, say. I want to create a new

[R] tapply within a data.frame: a simpler alternative?

2008-12-10 Thread baptiste auguie
Dear list, I have a data.frame with x, y values and a 3-level factor group, say. I want to create a new column in this data.frame with the values of y scaled to 1 by group. Perhaps the example below describes it best: x - seq(0, 10, len=100) my.df - data.frame(x = rep(x, 3), y=c(3*sin(x),

Re: [R] tapply within a data.frame: a simpler alternative?

2008-12-10 Thread Chuck Cleland
On 12/10/2008 12:02 PM, baptiste auguie wrote: Dear list, I have a data.frame with x, y values and a 3-level factor group, say. I want to create a new column in this data.frame with the values of y scaled to 1 by group. Perhaps the example below describes it best: x - seq(0, 10, len=100)

Re: [R] tapply within a data.frame: a simpler alternative?

2008-12-10 Thread hadley wickham
On Wed, Dec 10, 2008 at 11:02 AM, baptiste auguie [EMAIL PROTECTED] wrote: Dear list, I have a data.frame with x, y values and a 3-level factor group, say. I want to create a new column in this data.frame with the values of y scaled to 1 by group. Perhaps the example below describes it best:

Re: [R] tapply within a data.frame: a simpler alternative?

2008-12-10 Thread Peter Dalgaard
baptiste auguie wrote: Dear list, I have a data.frame with x, y values and a 3-level factor group, say. I want to create a new column in this data.frame with the values of y scaled to 1 by group. Perhaps the example below describes it best: x - seq(0, 10, len=100) my.df - data.frame(x =

Re: [R] tapply within a data.frame: a simpler alternative?

2008-12-10 Thread baptiste auguie
Excellent! I completely forgot its name and existence. Perhaps ave should be mentioned on the help page of either by, tapply, split. Many thanks, baptiste On 10 Dec 2008, at 17:20, Chuck Cleland wrote: On 12/10/2008 12:02 PM, baptiste auguie wrote: Dear list, I have a data.frame with x,

Re: [R] tapply within a data.frame: a simpler alternative?

2008-12-10 Thread baptiste auguie
On 10 Dec 2008, at 17:25, hadley wickham wrote: On Wed, Dec 10, 2008 at 11:02 AM, baptiste auguie [EMAIL PROTECTED] wrote: Dear list, I have a data.frame with x, y values and a 3-level factor group, say. I want to create a new column in this data.frame with the values of y scaled to 1