Re: [R] R Help-how to use sapply w/tapply

2013-10-14 Thread arun
Hi, Try: Gene[,-1] <- lapply(Gene[,-1],function(x) {x[sample(length(x),1)] <- NA;x}) A.K. I got it guys MeanofGenotype <-sapply(2:8, function(k) tapply(Gene[,k] , Gene$Genotype, mean)) I was wondering if now you guys can help me on how to insert a random NA to each column. The question i

Re: [R] R Help-how to use sapply w/tapply

2013-10-14 Thread arun
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)