[Rd] xtabs, drop.unused.levels (PR#1041)
Martin Lenze
martin.lenze@to.com
Mon, 6 Aug 2001 11:04:33 +0200 (W. Europe Daylight Time)
Many, many thanks for your answers, especially within this astonishing
timeframe.
Your solutions worked well. I changed the lines pointed out in
<R-HOME>/library/R/base and now it works as expedted.
Hopefully I'll be able to track down such mistakes myself sometimes.
with kindest regards
Martin Lenze
-------------------------------------------------------
martin.lenze@to.com, http://www.to.com/
Thinking Objects Software GmbH
Lilienthalstr. 2, 70825 Stuttgart-Korntal, Germany
office +49 711 88770-400, fax +49 711 88770-449
mobile +49 170 7917721, home +49 6221 618036
On Sun, 5 Aug 2001, Prof Brian D Ripley wrote:
PBDR>Date: Sun, 5 Aug 2001 19:34:45 +0100 (BST)
PBDR>From: Prof Brian D Ripley <ripley@stats.ox.ac.uk>
PBDR>To: martin.lenze@to.com
PBDR>Cc: r-devel@stat.math.ethz.ch, R-bugs@biostat.ku.dk
PBDR>Subject: Re: [Rd] xtabs, drop.unused.levels (PR#1041)
PBDR>
PBDR>On Sun, 5 Aug 2001 martin.lenze@to.com wrote:
PBDR>
PBDR>> Full_Name: Martin Lenze
PBDR>> Version: 1.3.0 22.06.2001
PBDR>> OS: win32,x86
PBDR>> Submission from: (NULL) (194.221.251.1)
PBDR>>
PBDR>>
PBDR>> As a newbie I'm not sure, whether this is a bug, but I don't know how to get
PBDR>> around this behaviour:
PBDR>> > x <- list("A"=rep(c(1:5),30),
PBDR>> + "B"=c(rep(letters[1:3],30),rep(letters[2:4],20)))
PBDR>> > y <- as.data.frame(x)
PBDR>> > xtabs(~A+B,y)
PBDR>> B
PBDR>> A a b c d
PBDR>> 1 6 10 10 4
PBDR>> 2 6 10 10 4
PBDR>> 3 6 10 10 4
PBDR>> 4 6 10 10 4
PBDR>> 5 6 10 10 4
PBDR>> > y <- subset(y,B!="d")
PBDR>> > xtabs(~A+B,y,drop.unused.levels=TRUE)
PBDR>> B
PBDR>> A a b c d
PBDR>> 1 6 10 10 0
PBDR>> 2 6 10 10 0
PBDR>> 3 6 10 10 0
PBDR>> 4 6 10 10 0
PBDR>> 5 6 10 10 0
PBDR>>
PBDR>> I'd expect "xtabs" to drop "d".
PBDR>
PBDR>The line
PBDR>
PBDR> x <- if (is.null(y))
PBDR> do.call("table", mf)
PBDR>
PBDR>should be
PBDR>
PBDR> x <- if (is.null(y))
PBDR> do.call("table", by)
PBDR>
PBDR>Currently drop.unused.levels=TRUE is ignored unless there is a response.
PBDR>
PBDR>--
PBDR>Brian D. Ripley, ripley@stats.ox.ac.uk
PBDR>Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
PBDR>University of Oxford, Tel: +44 1865 272861 (self)
PBDR>1 South Parks Road, +44 1865 272860 (secr)
PBDR>Oxford OX1 3TG, UK Fax: +44 1865 272595
PBDR>
PBDR>
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._