[R] argument 'exclude' in function xtabs
Erik Iverson
iverson at biostat.wisc.edu
Fri Apr 24 19:13:21 CEST 2009
> 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
More information about the R-help
mailing list