[R] covariance

Petr Savicky savicky at cs.cas.cz
Fri Feb 17 22:54:01 CET 2012


On Fri, Feb 17, 2012 at 11:06:23PM +0300, Naser Albalwi wrote:
> 
> Thank, thats what I need, using> the built-in help system and R's capability to allow you to view source code for functions,   but how???

Hi.

First, type "cov" without quotation marks to R's prompt. The
printed code calls .Internal(cov(...)), which means that the
main part is done in C code. Then, it is probably the best to
download R sources and unpack. The code for cov() is in the
file R/src/main/cov.c. The call goes first to function do_cov().
Then you have to search a bit. The main part is computed in
one of the functions cov_pairwise1(), cov_pairwise2(),
cov_complete1(), or cov_complete2(). Probably, other members
of the list may correct me, if this is not correct.

Basic formulas for the covariance are at Wikipedia

  http://en.wikipedia.org/wiki/Covariance

Hope this helps.

Petr Savicky.



More information about the R-help mailing list