sapply(seq_len(nrow(x)), function(i) var(x[i,], y[i,])) Gabor
On Sun, Apr 19, 2009 at 7:12 PM, Benny Chain <b.ch...@ucl.ac.uk> wrote: > Does anyone know a way to calculate the covariances between two > arrays/matrices x and y, row by row. i.e. var(x[n,],y[n,]) for all n ? > > Benjamin Chain > Division of Infection and Immunity > Windeyer Building > UCL, 46 Cleveland St. > London W1T 4JF > Fax 00 44 20 7679 9301 > > ______________________________________________ > 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. > -- Gabor Csardi <gabor.csa...@unil.ch> UNIL DGM ______________________________________________ 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.