I am not able to generate the mean of the value column. This is a similar/duplicate question that I posted earlier.
library(dplyr)
df <- data.frame(Dose = c(1, 1, 1, 1, 1, 1, 10, 10, 10, 10, 10, 10),
Route = c('IV','IV','IV','PO','PO','PO','IV','IV','IV','PO','PO','PO'),
Timepoint = c(0.25,0.25,0.25,0.25,0.25,0.25,0.5,0.5,0.5,0.5,0.5,0.5),
value = c(207,181,201,505,180,309,123,122,137,441,335,402))
mean.df <- df %>% aggregate(value~Timepoint + Dose + Route, FUN = mean)
Error in aggregate.data.frame(., value ~ Timepoint + Dose + Route, FUN = mean) :
'by' must be a list
When I try this:
mean.df <- df %>% group_by(Timepoint, Dose, Route) %>% summarize(mean_value=mean(value))
I get this instead of a table with mean values based on Timepoint, Dose and Route.
mean_value
1 261.9167
What am I missing?