Skip to content
Back to formatted view

Raw Message

Message-ID: <78f97d76eaf8fb53259527f46381b146@biostat.wisc.edu>
Date: 2009-04-24T17:13:21Z
From: Erik Iverson
Subject: argument 'exclude' in function xtabs
In-Reply-To: <2d0450630904241002h23b92246ifacdba78f450d638@mail.gmail.com>

> I was willing to use argument 'exclude' in function xtabs to remove some
> levels of factors (xtabs help page says '"exclude: a vector of values to
> be excluded when forming the set of levels of the classifying factors").


I think I see what's happening, and it's a little confusing to me, too.  
If your classifying factor to xtabs is not
actually a factor, but say, a character vector, it will be converted to a
factor
while using the "exclude" argument.  However, if it already is a factor,
this does not happen.
So, for example, contrast:

trt.char <- c("A","B","C","A","B","C")
xtabs(~trt.char, exclude = "B")

with

trt.fac <- factor(c("A","B","C","A","B","C"))
xtabs(~trt.fac, exclude = "B")

Hope that helps,
Erik Iverson