[R] number of levels for a factor

Aimin Yan aiminy at iastate.edu
Thu Mar 1 19:17:09 CET 2007


I have temp list which have 19 data.frame
I want to get number of levels for pr in the first dat.frame
I do this like this:
temp[[1]]$pr just has "1A24"
after I do nlevels(temp[[1]]$pr)
I expect to get 1, but I get 19

anyone know why?

 > tail(temp[[1]]$pr)
[1] 1A24 1A24 1A24 1A24 1A24 1A24
19 Levels: 1A24 1A57 1A5J 1A6X 1AB7 1AF8 1AFI 1AGG 1AH9 1AHL 1AJ3 1AJW ... 1AZK
 > nlevels(temp[[1]]$pr)
[1] 19

Aimin



More information about the R-help mailing list