tapply not simplifying to vector? (PR#320)

maechler@stat.math.ethz.ch maechler@stat.math.ethz.ch
Thu, 11 Nov 1999 11:54:10 +0100 (MET)

>>>>> "MatW" == Matthew Wiener <mcw@ln.nimh.nih.gov> writes:

    MatW> The help file for tapply says that if simplify is true, and the
    MatW> result of the calculation is always a scalar, then tapply will
    MatW> return a vector.

    MatW> Nonetheless:

    >> t1 <- tapply(runif(10), rep(1:5, 2), mean)  
    >> is.vector(t1)  
    R> [1] FALSE 
    >> is.array(t1) 
    R> [1] TRUE


all correct.

The question really is if the bug is in the code or the documentation.

Here you get a 1D array, something quite rare (but appearing more and more
in recent discussions...).

One could argue that the current behavior of tapply() to always return an
array if simplify = TRUE  is more consistent, than what the doc says should
happen (coercing 1D arrays to vectors).
Otoh, the protoype  *does* return a vector in this case,
and 1D arrays can be a pain... in other places.

I'm pro fixing this.
and I'll do if I don't hear protests..

    MatW>   <....>

    MatW> Hope this report helps.

yes indeed, thank you!
R's quality is growing partly because of such fine bug reports!

    MatW> Thanks for the terrific software.

you're welcome!

Martin Maechler <maechler@stat.math.ethz.ch>	http://stat.ethz.ch/~maechler/
Seminar fuer Statistik, ETH-Zentrum  LEO D10	Leonhardstr. 27
ETH (Federal Inst. Technology)	8092 Zurich	SWITZERLAND
phone: x-41-1-632-3408		fax: ...-1228			<><

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