[R] Problems with factor
Peter Dalgaard BSA
p.dalgaard at biostat.ku.dk
Wed Jul 31 20:00:51 CEST 2002
ripley at stats.ox.ac.uk writes:
> On Wed, 31 Jul 2002, kjetil halvorsen wrote:
>
> > 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.
>
> You have coercion going on there. Here is a simpler example:
>
> > x <- factor(letters)
> > ifelse(x=="a", "a", x)
> [1] "a" "2" "3" "4" "5" "6" "7" "8" "9" "10" "11" "12" "13" "14" "15"
> [16] "16" "17" "18" "19" "20" "21" "22" "23" "24" "25" "26"
..and even
> c("a",x)
[1] "a" "1" "2" "3" "4" "5" "6" "7" "8" "9" "10" "11" "12" "13" "14"
[16] "15" "16" "17" "18" "19" "20" "21" "22" "23" "24" "25" "26"
--
O__ ---- Peter Dalgaard Blegdamsvej 3
c/ /'_ --- Dept. of Biostatistics 2200 Cph. N
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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