From bert_gunter@merck.com  Thu Feb 13 15:10:05 2003
From: bert_gunter@merck.com (bert_gunter@merck.com)
Date: Thu Feb 13 15:10:05 2003
Subject: [Rd] colSums etc. documentation (PR#2545)
Message-ID: <200302131409.h1DE9j35028081@pubhealth.ku.dk>

For your consideration:

> z
     [,1] [,2]
[1,]    1   NA
[2,]    2   NA
[3,]    3   NA


> colSums(z)
[1]  6 NA

Correct, according to the documentation

> colSums(z,na.rm=T)
[1] 6 0

Surprising to me, but, as documented, correctly consistent with apply() and 
>sum(NULL)
[1] 0

The documentation for sum() explicitly notes that the sum of an empty set is
0 by definition, so that users will not get caught by this behavior (or at
least cannot complain about it if they are). I wonder if it might be wise to
include this note in the documentation for colSums, colMeans, etc. too, as
the current Help file says only:
"If there are no non-missing values in a range to be summed over, the
component of the output is set to NA."
This is obviously the case only when na.rm=F.
Cheers,
Bert Gunter
Biometrics Research
Merck & Company
PO Box 200, Rahway, NJ 07065-0900
Ph: (732) 594-7765    Fax: 594-1565

"The business of the statistician is to catalyze the scientific learning
process."    --  George E.P. Box







------------------------------------------------------------------------------



[Rd] colSums etc. documentation (PR#2545)
bert_gunter@merck.com