[R] Problems with factor

kjetil halvorsen kjetilh at umsanet.edu.bo
Wed Jul 31 17:50:01 CEST 2002


Hola!

Why does I get only the underlying representation, and not the level
names, in the following code to recode a factor? Seems like a bug to me.

> attach(Malaria)
> Malaria$TratUl <- factor(ifelse(Malaria$DiaC>0, 
+                          ifelse(Malaria$Trat=="QT", "SP", "QT"),
+                          Malaria$Trat)) 
> Malaria$TratUl
 [1] 1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  QT 2  2  2  2  2  QT
QT 2 
[25] 2  2  QT 2  2  2 
Levels:  1 2 QT 
> Malaria$Trat
 [1] QT QT QT QT QT QT QT QT QT QT QT QT QT QT QT SP SP SP SP SP SP SP
SP SP
[25] SP SP SP SP SP SP
Levels:  QT SP 


Kjetil Halvorsen
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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