Peter Dalgaard wrote:
> Rolf Turner wrote:
>   
>>     P.S.  ***Are*** there any risks/dangers in following Christos 
>> Hatzis' suggestion of simply doing
>>
>>             levels(fff) <- c("U","A","S")       ???
>>     
> Not if the levels are right to begin with.
>
> Problems only arise if fff somehow becomes a two-level factor, e.g. if 
>   
Doh. Sorry. Mixing up the examples there:  "...arise if fff somehow 
loses levels..." the example below of course has two levels reduced to a 
one.

> you do
>    fff <- fff[2:3, drop=TRUE].
> Then you can get this effect:
>
>  >  fff
> [1] Unit        Scholarship Scholarship Unit      
> Levels: Scholarship Unit
>  > fff[2:3, drop=TRUE]
> [1] Scholarship Scholarship
> Levels: Scholarship
>  > fff[-(2:3), drop=TRUE]
> [1] Unit Unit
> Levels: Unit
>  > ggg <- fff[2:3, drop=TRUE]
>  > levels(ggg) <- c("a","b")
>  > ggg
> [1] a a
> Levels: a b
>  > ggg <- fff[-(2:3), drop=TRUE]
>  > levels(ggg) <- c("a","b")
>  > ggg
> [1] a a
> Levels: a b
>
>
>   


-- 
   O__  ---- Peter Dalgaard             Ă˜ster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark          Ph:  (+45) 35327918
~~~~~~~~~~ - ([EMAIL PROTECTED])                  FAX: (+45) 35327907

______________________________________________
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.

Reply via email to