[R] Subset: data frames and factor levels

Agustin Lobo Agustin.Lobo at ija.csic.es
Tue Apr 1 09:43:00 CEST 2008


I'm doing:
etni <- subset(etni, NAMECOM!="Maniquisito")

where etni is a data.frame, NAMECOM a factor and "Maniquisito" labels
a row that I want to delete.

The problem is that while the row is deleted, the factor level is still 
there (I can see "Maniquisito" if I do levels(etni$NAMECOM) ).

I know I can get the appropriate levels by:
so I could
etni$NAMECOM <- factor(etni$NAMECOM)

but there are other columns in etni that are factors as well. Do I have 
to take
care of each factor column? Should not subset take care of recalculating
the factor levels automatically?


Dr. Agustin Lobo
Institut de Ciencies de la Terra "Jaume Almera" (CSIC)
LLuis Sole Sabaris s/n
08028 Barcelona
Tel. 34 934095410
Fax. 34 934110012
email: Agustin.Lobo at ija.csic.es

More information about the R-help mailing list