thank you sorry, but i missed that thread your solution works (of cause) hopefully the code and not the documentation will be corrected as the drop argument comes very convenient or maybe as a new option: drop.unused.levels=T regards soren
btw how do i interpret an assigment to a square bracket? d2[] <- lapply(d2, function(x) if (is.factor(x)) factor(x) else x) ----- Original Message ----- From: "Peter Dalgaard" <[EMAIL PROTECTED]> To: "Søren Merser" <[EMAIL PROTECTED]> Cc: "R - help" <[EMAIL PROTECTED]> Sent: Sunday, June 27, 2004 11:38 AM Subject: Re: [R] subset drop unused levels > Søren Merser <[EMAIL PROTECTED]> writes: > > > hi there > > > > tried to use subset with drop=TRUE, but all the 'old' levels are preserved, > > i.e. when calling e.g. ftable a lot of zeros are displayed > > > > >x<-subset(LREG, (kir=='AA' | kir=='BB') & (type=='t1' | otype=='t2'), > > drop=TRUE, select=c(event, kir, type)) > > > ftable(x) > > > > i explicit have to call factor like > > >ftable(event~factor(kir)+factor(type)) > > > > any hints? > > Yes, the drop argument is misdocumented. It actually does the same as > the drop argument to [.data.frame. It was on this very list just > eleven days ago, see e.g. the below ref., including what to do if you > really want to get rid of unused levels > > http://www.mail-archive.com/[EMAIL PROTECTED]/msg22459.html > > (yet another interface to the archives...) > > -- > 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 > ______________________________________________ [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