Hi, (Please use ?dput() to share the example dataset. Avoid using images to show dataset. Also, please read the posting guide esp. regarding home work, assignments etc.)
res <- sapply(Gene[,-1],function(x) tapply(x,list(Gene$Genotype),mean)) #or res2 <- aggregate(.~Genotype, data=Gene,mean) #or library(plyr) res3 <- ddply(Gene,.(Genotype),numcolwise(mean)) identical(res2,res3) #[1] TRUE resNew <- data.frame(Genotype=rownames(res),res,stringsAsFactors=FALSE) attr(resNew,"row.names") <- attr(res2,"row.names") identical(resNew,res2) #[1] TRUE A.K. So I'm having a problem with the part b of the assignment. This is the question This is how I solved Part A now for Part B Am i supposed to do something along the lines of sapply(tapply(Gene[ , ], Gene$Genotype), mean) This doesn't work. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.