Re: [R] How to Calculate the Mean by Multiple Groups in R

2023-10-24 Thread Gabor Grothendieck
A variation is to remove Well and then we can use dot to refer to the remaining columns. aggregate(cbind(OD, ODnorm) ~ . , subset(df, select = - Well), mean) On Tue, Oct 24, 2023 at 8:32 AM Luigi Marongiu wrote: > > Hello, > I have a data frame with different groups (Time, Target, Conc) and

Re: [R] How to Calculate the Mean by Multiple Groups in R

2023-10-24 Thread Luigi Marongiu
Thank you On Tue, Oct 24, 2023 at 3:01 PM peter dalgaard wrote: > > Also, > > > aggregate(cbind(OD, ODnorm) ~ Time + Target + Conc, data = df, FUN = "mean") > Time Target Conc ODODnorm > 11 BACT1 765. 108.3 > 21 BACT2 745. 88.3 > 31 BACT3

Re: [R] How to Calculate the Mean by Multiple Groups in R

2023-10-24 Thread peter dalgaard
Also, > aggregate(cbind(OD, ODnorm) ~ Time + Target + Conc, data = df, FUN = "mean") Time Target Conc ODODnorm 11 BACT1 765. 108.3 21 BACT2 745. 88.3 31 BACT3 675. 18.0 (You might wish for "cbind(OD,ODnorm) ~ . - Well", but aggre

Re: [R] How to Calculate the Mean by Multiple Groups in R

2023-10-24 Thread Luigi Marongiu
Thank you, the last is exactly what I was looking for. On Tue, Oct 24, 2023 at 2:41 PM Sarah Goslee wrote: > > Hi, > > I think you're misunderstanding which set of variables go on either > side of the formula. > > Is this what you're looking for? > > > aggregate(OD ~ Time + Target + Conc, data =

Re: [R] How to Calculate the Mean by Multiple Groups in R

2023-10-24 Thread Sarah Goslee
Hi, I think you're misunderstanding which set of variables go on either side of the formula. Is this what you're looking for? > aggregate(OD ~ Time + Target + Conc, data = df, FUN = "mean") Time Target Conc OD 11 BACT1 765. 21 BACT2 745. 31 BACT3 675

[R] How to Calculate the Mean by Multiple Groups in R

2023-10-24 Thread Luigi Marongiu
Hello, I have a data frame with different groups (Time, Target, Conc) and each entry has a triplicate value of the measurements OD and ODnorm. How can I merge the triplicates into a single mean value? I tried the following: ``` df = data.frame(Time=rep(1, 9), Well=paste("A", 1:9, sep=""),