[R] Levels number of a factor object

Thomas Petzoldt thpe at hhbio.wasser.tu-dresden.de
Fri Jan 23 16:05:34 CET 2004


Laurent Houdusse schrieb:

> 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

Simply try:

length(levels(groups))

Thomas P.




More information about the R-help mailing list