There are multiple solutions like this posted in this portal to calculate mean for values in a column based on another column by grouping using R. However, I am not able to calculate mean of replicate experiment result values in a column based on multiple columns using R. I need to keep all the columns except the Rep column, and the value column replaced with mean values based on Rep and all other columns.
library(dplyr)
Cmpd1 <- c("abc1","abc1","abc1","abc1","abc1","abc1","abc1","abc1","abc1","abc1","abc1","abc1")
cmpd1_conc <- c("0.0412","0.0412","0.1235","0.1235","0.3704","0.3704","1.1111","1.1111","3.3333","3.3333","10","10")
Cmpd2 <- c("xyz1","xyz1","xyz1","xyz1","xyz1","xyz1","xyz1","xyz1","xyz1","xyz1","xyz1","xyz1")
cmpd2_conc <- c("1","1","1","1","1","1","1","1","1","1","1","1")
value <- c(157120,144160,110480,92600,100800,97600,92240,78800,67920,61520,37640,34240)
Plate <- c("Plate1","Plate1","Plate1","Plate1","Plate1","Plate1","Plate1","Plate1","Plate1","Plate1","Plate1","Plate1")
CL <- c("CL1","CL1","CL1","CL1","CL1","CL1","CL1","CL1","CL1","CL1","CL1","CL1")
Rep <- c(1,2,1,2,1,2,1,2,1,2,1,2)
Result <- data.frame(Cmpd1,cmpd1_conc, Cmpd2, cmpd2_conc, value, Plate, CL, Rep)
MeanResult <- Result %>%
group_by(Cmpd1, cmpd1_conc, Cmpd2,
cmpd2_conc, Plate, CL, Rep) %>%
summarize(MeanValue = mean(value))
I tried several ways as suggested in multiple entries in this portal in vain. I wish to know what am I missing.