# More on tapply and factors

Peter Dalgaard BSA p.dalgaard@biostat.ku.dk
06 Jan 1998 18:09:57 +0100

```Douglas Bates <bates@stat.wisc.edu> writes:

> > tapply( Machines\$Machine, Machines\$Worker, table )
> \$6
> integer(0)

Yuk! Apparently, the culprit is "split":

> f1<-gl(2,1,4)
> f2<-gl(2,2,4)
> dput(split(f1,f2))
list(1 = factor(c(1, 2), levels=1:0), 2 = factor(c(1, 2), levels=1:0))

> dput(f1)
structure(factor(c(1, 2, 1, 2), levels=1:2), class = "factor", .Label = c("1",
"2"))
> dput(f2)
structure(factor(c(1, 1, 2, 2), levels=1:2), class = "factor", .Label = c("1",
"2"))

I wonder if this is a side effect of the ...hmm... "undesirable
feature" of as.numeric(factor)??

--
O__  ---- Peter Dalgaard             Blegdamsvej 3
c/ /'_ --- Dept. of Biostatistics     2200 Cph. N
(*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk)             FAX: (+45) 35327907

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

```