Paul Lemmens <[EMAIL PROTECTED]> writes:

> >> Could you comment?
> >
> > Looks like a documentation bug. The actual code ends up  doing
> >
> >     x[r, vars, drop = drop]
> >
> > and "[.data.frame" will not drop factor levels. I wonder if it ever
> > did...
> >
> Bottomline: unless I find the time to submit a patch for
> '[.data.frame', I'll need to use the more elaborate way of dropping
> the unused levels?
> 
> Does "will not drop" imply that it cannot be programmed, should not be
> programmed, or has not been programmed yet?

Cannot. The drop argument is doing something different. 

Anyways, the way out is

 d2 <- subset(dd,c==1)
 ifac <- sapply(dd,is.factor)
 d2[ifac] <- lapply(d2[ifac],factor)

or 

 d2 <- subset(dd,c==1)
 d2[] <- lapply(d2, function(x) if (is.factor(x)) factor(x) else x) 



-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - ([EMAIL PROTECTED])             FAX: (+45) 35327907

______________________________________________
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to