Thank you very much. The advice I followed (and which, for some reason, I do
not see here right now) was to use 'droplevels'. I needed the command for
several variables at the same time, so this was very convenient.
>
Hello,
Have you tried 'droplevels':
test <-data.frame(a=as.factor(rep(c("f1","f2","f3"),10)),b=rep(c(1,2,3),10))
test2 <- subset(test,test$a=="f1")
summary(test2)
ab
f1:10 Min. :1
f2: 0 1st Qu.:1
f3: 0 Median :1
Mean :1
3rd Qu.:1
Max. :1
test3<-droplevels(test2)
summary(test3)
ab
f1:10 Min. :1
1st Qu.:1
Median :1
Mean :1
3rd Qu.:1
Max. :1
A.K.
>
--
View this message in context:
http://r.789695.n4.nabble.com/Remove-empty-levels-in-subset-tp873967p4634550.html
Sent from the R help mailing list archive at Nabble.com.
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.