[Rd] two minor bugs in rowsum()

From: William Dunlap <wdunlap_at_tibco.com>
Date: Fri, 25 Mar 2011 10:19:58 -0700

(a) In R 2.12.2 rowsum can overflow if given an integer input:
> rowsum(c(2e9L, 2e9L), c("a", "a"))

  a -294967296
> 2^32 + .Last.value

  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

R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Fri 25 Mar 2011 - 17:29:04 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 29 Mar 2011 - 14:10:40 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.

list of date sections of archive