[R] covariance

Gábor Csárdi csardi at rmki.kfki.hu
Sun Apr 19 19:17:27 CEST 2009


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.chain at 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 at 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.Csardi at unil.ch>     UNIL DGM




More information about the R-help mailing list