Thursday, January 20, 2011

R group by

# use aggregate(x, by, FUN, ...) to calculate the mean density grouped by concentration

res<-aggregate(DNase$density, list(DNase$conc) , mean)
names(res)<-c("Conc", "MeanDensity")
plot(res$Conc, res$MeanDensity, pch=20, xlab="Concentration", ylab="Mean density")

No comments: