variance/mean
Inline Below. -- Bert Bert Gunter Genentech Nonclinical Biostatistics 650-467-7374 -----Original Message----- From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of Wacek Kusnierczyk Sent: Sunday, March 22, 2009 2:16 AM To: rkevinburton at charter.net Cc: r-help at r-project.org Subject: Re: [R] variance/mean
rkevinburton at charter.net wrote:
At the risk of appearing ignorant why is the folowing true?
o <- cbind(rep(1,3),rep(2,3),rep(3,3))
var(o)
[,1] [,2] [,3]
[1,] 0 0 0
[2,] 0 0 0
[3,] 0 0 0
and
mean(o)
[1] 2
How do I get mean to return an array similar to var? I would expect in the
above example a vector of length 3 {1,2,3}.
You said: "you may well be ignorant about how var works with matrices, but this does not mean it's your fault. the documentation is typically cryptical." -- How so? ?var clearly states: " ... If x and y are matrices then the covariances (or correlations) between the columns of x and the columns of y are computed. " and the Arguments section says: x a numeric vector, matrix or data frame. y NULL (default) or a vector, matrix or data frame with compatible dimensions to x. The default is equivalent to y = x (but more efficient). This is as clear as I would know how to state. I think "...typically cryptical" is a canard and most unfair. -- Bert