[R] remove levels from a factor

Adrian Dusa dusa.adrian at gmail.com
Sat Aug 30 12:11:28 CEST 2008


Yuan Jian <jayuan2008 <at> yahoo.com> writes:

> [...snip...]
> 
> I want to remove level b because level b has less than 2.
> > f
> [1] a a
> Levels: a


> f[which(f %in% names(table(f))[table(f) >= 2]), drop=TRUE]
[1] a a
Levels: a

HTH,
Adrian



More information about the R-help mailing list