[R] dropping factor levels in subset

Douglas Bates bates at stat.wisc.edu
Mon Jun 30 19:00:52 CEST 2003


"Adaikalavan Ramasamy" <gisar at nus.edu.sg> writes:

> Another option is pruneLevels() in library nlme.
> 
> x <- factor( c( 0,1,2,1,2 ) )
> > x
> [1] 0 1 2 1 2
> Levels: 0 1 2
> > pruneLevels( x[-1] )
> [1] 1 2 1 2
> Levels: 1 2

That function has been removed from the latest release of the nlme
package because it not needed.  All uses of pruneLevels in nlme were
replaced by code of the form

 myfactor[] = myfactor[, drop = TRUE]




More information about the R-help mailing list