More on tapply and factors

Douglas Bates bates@stat.wisc.edu
Tue, 6 Jan 1998 09:59:46 -0600 (CST)


Here is an even more awkward property of tapply with factors.  What we 
want to do is to determine the modal value of the first factor given
the level of the second factor.  We do that by applying table in a
tapply call then finding the maximum count then ...

Turns out that table gives unexpected results in tapply.

> table(Machines$Machine)
 A  B  C 
18 18 18 
> tapply( Machines$Machine, Machines$Worker, table )
$6
integer(0)

$2
integer(0)

$4
integer(0)

$1
integer(0)

$3
integer(0)

$5
integer(0)

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._