Skip to content

Inconsistency between rowMeans documentation and reality?

3 messages · Gavin Simpson, Brian Ripley

#
Dear List,

I'm not even sure this is an issue or not, but ?rowMeans has:

Value:

     A numeric or complex array of suitable size, or a vector if the
     result is one-dimensional.  The ?dimnames? (or ?names? for a
     vector result) are taken from the original array.

     If there are no values in a range to be summed over (after
     removing missing values with ?na.rm = TRUE?), that component of
     the output is set to ?0? (?*Sums?) or ?NA? (?*Means?), consistent
     with ?sum? and ?mean?.

However the output of mean() and rowMeans() is not exactly the same when
all supplied values are missing.
[1] NaN
[1] NaN
[1] NA

So in one sense, the outputs are not consistent:
[1] TRUE
[1] FALSE

but in another they are:
[1] TRUE
[1] TRUE

I'm not familiar enough with the details to know if this even matters,
but wonder if something in the documentation needs a change or tweak to
clarify what is returned. As I say, in one sense the outputs are not
consistent.
R version 2.13.0 beta (2011-04-04 r55298)
Platform: x86_64-unknown-linux-gnu (64-bit)

locale:
 [1] LC_CTYPE=en_GB.utf8       LC_NUMERIC=C             
 [3] LC_TIME=en_GB.utf8        LC_COLLATE=en_GB.utf8    
 [5] LC_MONETARY=C             LC_MESSAGES=en_GB.utf8   
 [7] LC_PAPER=en_GB.utf8       LC_NAME=C                
 [9] LC_ADDRESS=C              LC_TELEPHONE=C           
[11] LC_MEASUREMENT=en_GB.utf8 LC_IDENTIFICATION=C      

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods  
[7] base     

loaded via a namespace (and not attached):
[1] tools_2.13.0

Thanks,

Gavin
6 days later
#
I suspect you omitted some of the help page:

   As they are written for speed, they blur over some of the subtleties
   of ?NaN? and ?NA?.

So, given that (and that real NA is a specific NaN) I think it is 
perfectly reasonable to claim they are consistent with mean.
On Tue, 5 Apr 2011, Gavin Simpson wrote:

            

  
    
#
On Mon, 2011-04-11 at 15:57 +0100, Prof Brian Ripley wrote:
Yes. My apologies, I don't know how I missed that - I did read it
several times aware that I might be overlooking something sensible such
as the sentence you quote.

Sorry for the noise.

G