[R] Factor names & levels
Damon Wischik
djw1005 at cam.ac.uk
Mon Dec 22 01:38:14 CET 2003
> I agree it may not be 100% clear but ?names does say
> "The default methods get and set the '"names"' attribute
> of a vector or list." and if you issue the command:
> methods("names")
> you find that the only non-default method is names.dist.
I still want to know how I should understand the following:
> x <- factor(c("one","three"))
> names(x) <- c("fred","jim")
> names(x)
[1] "fred" "jim"
class(x)
[1] "factor"
Given that names seems to work on factors, I can see two possibilities:
1. It is a bug that it acts as it does;
2. the default method does what it says in the help page, but also does
more than just this.
I don't know enough to look at the source code to find out what is going
on.
Damon.
More information about the R-help
mailing list