Skip to content
Back to formatted view

Raw Message

Message-ID: <200108051803.UAA11343@pubhealth.ku.dk>
Date: 2001-08-05T18:03:32Z
From: martin.lenze@to.com
Subject: xtabs, drop.unused.levels (PR#1041)

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

Kindest regards
M. Lenze


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