From wdunlap at tibco.com  Fri Mar 25 18:19:58 2011
From: wdunlap at tibco.com (William Dunlap)
Date: Fri, 25 Mar 2011 10:19:58 -0700
Subject: [Rd] two minor bugs in rowsum()
Message-ID: <77EB52C6DD32BA4D87471DCD70C8D70004086C27@NA-PA-VBE03.na.tibco.com>

(a) In R 2.12.2 rowsum can overflow if given an integer input:
  > rowsum(c(2e9L, 2e9L), c("a", "a"))
          [,1]
  a -294967296
  > 2^32 + .Last.value
     [,1]
  a 4e+09
Should it be changed to coerce its x argument to numeric
(double precision) so it always returns a numeric output?

(b) When rowsum is given an x containing both NaN and NA it
appears to use the last of the NaN/NA entries to determine
if the output is NaN or NA while the `+` function uses the
first:
  > z <- cbind( c(NA,NA), c(NA,NaN), c(NaN,NA), c(NaN,NaN))
  > rowsum(z, c("a","a"))
    [,1] [,2] [,3] [,4]
  a   NA  NaN   NA  NaN
  > z[1,,drop=FALSE] + z[2,,drop=FALSE]
       [,1] [,2] [,3] [,4]
  [1,]   NA   NA  NaN  NaN

(The name rowsum is a metabug, since it may be confused
with the entirely different rowSums, but it has been around
for a long time.)

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com 



[Rd] two minor bugs in rowsum()
William Dunlap