check ?"[.factor", you need:

fact[1:6, drop = TRUE]


Best,
Dimitris

----
Dimitris Rizopoulos
Ph.D. Student
Biostatistical Centre
School of Public Health
Catholic University of Leuven

Address: Kapucijnenvoer 35, Leuven, Belgium
Tel: +32/(0)16/336899
Fax: +32/(0)16/337015
Web: http://med.kuleuven.be/biostat/
     http://www.student.kuleuven.be/~m0390867/dimitris.htm


----- Original Message ----- 
From: "Afshartous, David" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Tuesday, September 12, 2006 5:22 PM
Subject: [R] levels of factor when subsetting the factor


>
> All,
>
> When I take a subset of a factor the reduced factor still maintains 
> all
> the original levels of the factor when say forming the key in a 
> plot.
> The data is correct, but the variable still "remembers" the original
> levels.  See below for reproducible code.  Does anyone know how to 
> fix
> this?
> cheers,
> dave
>
> fact = as.factor(c(rep("A", 3),rep("B", 3), rep("C", 3)))
> new.fact = fact[1:6]
>> new.fact
> [1] A A A B B B
> Levels: A B C    ## should only show A B
>
> ______________________________________________
> [email protected] 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.
> 


Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm

______________________________________________
[email protected] 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.

Reply via email to