[R] Levels number of a factor object

Peter Dalgaard p.dalgaard at biostat.ku.dk
Fri Jan 23 15:50:08 CET 2004


Laurent Houdusse <l.houdusse at cerep.fr> writes:

> Hi all!
> 
>     How to retrieve the levels number of a factor object?
>     See this code:
>     groups<-gl(4,10)
>     I want to retrieve the number of levels (4) of my object "groups"
>     I tried groups.levels but this don't work
> 
>     Thanks

Do you mean just

length(levels(groups))

?

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)             FAX: (+45) 35327907




More information about the R-help mailing list