brahm@alum.mit.edu
2003-Aug-13 00:05 UTC
[Rd] rowsum() may return a vector instead of a matrix (PR#3737)
If all rows are in the same "group", rowsum() returns a vector instead
of a
(1xN) matrix, contrary to documentation:
R> print(z <- rowsum(matrix(1:12, 3,4), rep("x",3)))
[1] 6 15 24 33
R> dim(z)
NULL
It worked correctly in version 1.4.0 but was broken by version 1.6.1. I'm
currently using 1.7.1 under Solaris 2.8.
--please do not edit the information below--
Version:
platform = sparc-sun-solaris2.8
arch = sparc
os = solaris2.8
system = sparc, solaris2.8
status =
major = 1
minor = 7.1
year = 2003
month = 06
day = 16
language = R
Search Path:
.GlobalEnv, package:misc, package:io, package:arrays, package:ls1,
package:obsi, package:g.data, package:db, package:ts, package:ctest, Autoloads,
package:base
--
-- David Brahm (brahm@alum.mit.edu)
Thomas Lumley
2003-Aug-13 01:55 UTC
[Rd] rowsum() may return a vector instead of a matrix (PR#3737)
On Wed, 13 Aug 2003 brahm@alum.mit.edu wrote:> If all rows are in the same "group", rowsum() returns a vector instead of a > (1xN) matrix, contrary to documentation: >Yes, and it appears to be deliberate since rowsum.default() ends with drop(rval), though I don't remember why it was this way. Is there a strong preference for changing the function vs changing the documentation? -thomas
David Brahm
2003-Aug-13 15:38 UTC
[Rd] rowsum() may return a vector instead of a matrix (PR#3737)
I wrote:> If all rows are in the same "group", rowsum() returns a vector instead of a > (1xN) matrix, contrary to documentation:Thomas Lumley <tlumley@u.washington.edu> replied:> Is there a strong preference for changing the function vs changing the > documentation?I could live with it either way, but I will point out that the "Examples" section implies an equivalence between: R> xsum <- rowsum(x, group) and R> xsum2 <- tapply(x, list(group[row(x)], col(x)), sum) R> xsum3 <- aggregate(x, list(group), sum) which is broken by this new behavior; xsum2 and xsum3 are (1xN) matrices. -- -- David Brahm (brahm@alum.mit.edu)