Skip to content
Prev 169441 / 398506 Next

subset problem (reducing from six to two levels)

Ine wrote:
R does not "assign 'not available'" (look at the subsetted data).

However, factors do not lose levels just because they are not present in 
a subset of data. There are good reasons for that, but let's not go 
there this time (look in the list archives if you care). To get rid of 
unwanted levels, use

FactorXX <- factor(FactorX, levels=c("Level1","Level2"))

or just factor(FactorX) if you know that both levels are present (or 
don't care).