If
its desired that name act on factors in the same way that names
act on vectors and lists then the methods I provided would not
be correct and, as Peter points out, the other factor methods
would have to be examined, as well, to ensure that they all
work properly with names.
Thank
Wischik [EMAIL PROTECTED]
To: Gabor Grothendieck [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Subject: Re: [R] Factor names levels
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
Gabor Grothendieck [EMAIL PROTECTED] writes:
For it to be well defined, there would need to be a names
method and a names- method for the factor class or else
the default methods would have to be able to handle factors.
Not only that but other methods for factors need to know about the
names
PROTECTED]
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED], [EMAIL PROTECTED]
Subject: Re: [R] Factor names levels
Gabor Grothendieck [EMAIL PROTECTED] writes:
For it to be well defined, there would need to be a names
method and a names- method for the factor class or else
the default
names() is only defined for vectors and lists and factors are
neither. See ?vector and ?names for more info.
---
From: djw1005 at cam.ac.uk
Subject: [R] Factor names levels
When I alter the levels of a factor, why does it alter the names too?
f - factor(c(A=one,B=two,C=one,D=one,E=three
When I alter the levels of a factor, why does it alter the names too?
f - factor(c(A=one,B=two,C=one,D=one,E=three),
levels=c(one,two,three))
names(f)
-- gives [1] A B C D E
levels(f) - c(un,deux,trois)
names(f)
-- gives NULL
I'm using R 1.8.0 for Windows.
Damon.