[Rd] xtabs, drop.unused.levels (PR#1041)
Prof Brian D Ripley
ripley@stats.ox.ac.uk
Sun, 5 Aug 2001 19:34:45 +0100 (BST)
On Sun, 5 Aug 2001 martin.lenze@to.com wrote:
> Full_Name: Martin Lenze
> Version: 1.3.0 22.06.2001
> OS: win32,x86
> Submission from: (NULL) (194.221.251.1)
>
>
> As a newbie I'm not sure, whether this is a bug, but I don't know how to get
> around this behaviour:
> > x <- list("A"=rep(c(1:5),30),
> + "B"=c(rep(letters[1:3],30),rep(letters[2:4],20)))
> > y <- as.data.frame(x)
> > xtabs(~A+B,y)
> B
> A a b c d
> 1 6 10 10 4
> 2 6 10 10 4
> 3 6 10 10 4
> 4 6 10 10 4
> 5 6 10 10 4
> > y <- subset(y,B!="d")
> > xtabs(~A+B,y,drop.unused.levels=TRUE)
> B
> A a b c d
> 1 6 10 10 0
> 2 6 10 10 0
> 3 6 10 10 0
> 4 6 10 10 0
> 5 6 10 10 0
>
> I'd expect "xtabs" to drop "d".
The line
x <- if (is.null(y))
do.call("table", mf)
should be
x <- if (is.null(y))
do.call("table", by)
Currently drop.unused.levels=TRUE is ignored unless there is a response.
--
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._