[R] remove levels from a factor

Adrian Dusa dusa.adrian at gmail.com
Sat Aug 30 12:16:47 CEST 2008


Adrian Dusa <dusa.adrian <at> gmail.com> writes:
> > [...snip...]
> > f[which(f %in% names(table(f))[table(f) >= 2]), drop=TRUE]
> [1] a a
> Levels: a

Or, more simple:

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

Adrian



More information about the R-help mailing list