[R] Problems with levels of factors
Uli Flenker; Raum 704
uli at biochem.dshs-koeln.de
Thu Aug 10 19:56:06 CEST 2000
Dear R-helpers,
I frequently run into problems when I modify elements of factors (R 1.0.0,
Linux 2.0.25). For example, after splitting a data frame accordinng to
whatever criterion, it might well happen that not all levels of a factor
are present in all new data frames. However, R doesn't seem to care about.
When performing some kind of analysis seperately on the new frames, each
time the unreduced number of levels is present.
That can be very problematic, as a lot of methods tend to crash because no
data are found for the "lost" level.
Neither explicit setting of "data=data.frame.xyz" nor any straightforward
use of "detach()" or "attach()" nor
"levels(problem.factor)<-c("reduced","levels", ...)" did help.
In the latter case I obtain
Error in levels<-.factor(*tmp*, value = c("A", "B")) :
number of levels differs
no matter whether the relevant data.frame is attached to the search list
or not, no matter whether the number of levels is appropriate in that data
frame and no matter whether an "extra" factor of the name exists or not.
I also tried to modify the attributes of the problematic factors
explicitly without succes.
The persistance of levels of factors once established seems to be so
robust that I suspect its a feature. As far as I remember no one
compalained about this properties so far. Am I missing something obvious?
Are there any suggestions for workarounds?
Thanks in advance ...
Uli Flenker
Institute of Biochemistry
German Sports University Cologne
Carl-Diem-Weg 6
50933 Cologne / Germany
Phone 0049/0221/4982-493
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list