[R] Subset: data frames and factor levels

From: Agustin Lobo <Agustin.Lobo_at_ija.csic.es>
Date: Tue, 01 Apr 2008 09:43:00 +0200


Hi!

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: levels(factor(etni$NAMECOM))
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?

Thanks!

Agus

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

______________________________________________
R-help_at_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.
Received on Tue 01 Apr 2008 - 08:02:22 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 01 Apr 2008 - 08:30:25 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive