[R] Factor names & levels

Damon Wischik djw1005 at cam.ac.uk
Sun Dec 21 18:54:25 CET 2003


> names() is only defined for vectors and lists and factors are
> neither.  See ?vector and ?names for more info.

?vector tells me that factors are not vectors, but ?names does not tell me
that names() is only defined for vectors and lists. If it were, how
should I understand the following?

> x <- factor(c("one","three"))
> names(x) <- c("fred","jim")
> names(x)
[1] "fred" "jim" 
> class(x)
[1] "factor"




More information about the R-help mailing list