[R] Subset: data frames and factor levels

Weidong Gu wgu at uab.edu
Tue Apr 1 14:38:05 CEST 2008

Try drop.levels in library gdata.

Weidong Gu, 
Department of Medicine
University of Alabama, Birmingham
1900 University Blvd., Birmingham, Alabama 35294
Email: wgu at uab.edu
PH: (205)-975-9053

-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org]
On Behalf Of Agustin Lobo
Sent: Tuesday, April 01, 2008 3:26 AM
To: Stefan Grosse
Cc: r-help at r-project.org
Subject: Re: [R] Subset: data frames and factor levels

Thanks, problem solved thanks to your hints, but, within subset(), 
drop=T still keeps
the unused levels (I'm using 2.6.1 on win).

Stefan Grosse escribió:
> On Tuesday 01 April 2008 09:43:00 am Agustin Lobo wrote:
> AL> I'm doing:
> AL> etni <- subset(etni, NAMECOM!="Maniquisito")
> AL>
> AL> where etni is a data.frame, NAMECOM a factor and "Maniquisito"
> AL> a row that I want to delete.
> AL>
> AL> The problem is that while the row is deleted, the factor level is
> AL> there (I can see "Maniquisito" if I do levels(etni$NAMECOM) ).
> See
> Stefan

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

R-help at r-project.org mailing list
PLEASE do read the posting guide
and provide commented, minimal, self-contained, reproducible code.

More information about the R-help mailing list