[R] Levels number of a factor object

Spencer Graves spencer.graves at pdf.com
Fri Jan 23 15:49:35 CET 2004


 > groups<-gl(4,10)
 > levels(groups)
[1] "1" "2" "3" "4"
 > length(levels(groups))
[1] 4

      Is this what you want? 
      spencer graves

Laurent Houdusse wrote:

>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
>
>
>Laurent Houdusse 
>Analyste Programmeur
>
>______________________________________________
>R-help at stat.math.ethz.ch mailing list
>https://www.stat.math.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>  
>




More information about the R-help mailing list