[Rd] rowsum dimnames (PR#1092)
ripley@stats.ox.ac.uk
ripley@stats.ox.ac.uk
Sun, 16 Sep 2001 13:11:39 +0200 (MET DST)
On Fri, 14 Sep 2001 brahm@alum.mit.edu wrote:
> The result of rowsum() in R doesn't have the dimnames I'd expect, e.g.:
>
> > rowsum(matrix(1:12, 3,4), c("Y","X","Y"))
> [,1] [,2] [,3] [,4]
> 1 2 5 8 11
> 2 4 10 16 22
>
> whereas S-Plus gives the more useful result:
> [,1] [,2] [,3] [,4]
> X 2 5 8 11
> Y 4 10 16 22
>
> This is because R's rowsum() code gives the first dimnames as "ugroup", which
> is a factor, rather than "as.character(ugroup)". Similarly for the assignment
> of names(x) in the case where x is a vector.
>
> I'm using R 1.3.0 on Solaris 2.6. Help says rowsum's author is Terry Therneau.
> Thanks!
> -- David Brahm (a215020@agate.fmr.com)
Change a couple of lines to
dimnames(new.x) <- list(as.character(ugroup), colnames(x))
names(new.x) <- as.character(ugroup)
(as you seem to be aware).
Done in the sources for 1.4.0.
--
Brian D. Ripley, ripley@stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272860 (secr)
Oxford OX1 3TG, UK Fax: +44 1865 272595
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._