> Works for me: > x <- read.csv('christina.txt') > > x.list <- by(x, x$gen, function(d) { > d.clean <- d[,-1] > cov(d.clean, y= NULL, use= "complete.obs", method="pearson") > } ) > >note that the output is a list, where each element corresponds to one >level of 'gen'. if you need to write each element out to a file, see >?sapply or ?lapply .
Yes, how would I do that? The usage of sapply is pretty hard to understand, at least at first glance, and I have never played with it before. I will need to output all of the covariance matrices to one CSV or text file (there's probably some sort of "append = TRUE" argument involved). Does anyone know how to do this easily? [[alternative HTML version deleted]] ______________________________________________ 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.