[R] as.logical(factor) behaviour

Philippe Grosjean phgrosjean at sciviews.org
Sun Aug 15 10:32:40 CEST 2010


Hello,

According to ?as.logical:

"as.logical attempts to coerce its argument to be of logical type. For 
factors, this uses the levels (labels)."

However,

 > as.logical(factor(c("FALSE", "TRUE")))
[1] TRUE TRUE

Shouldn't it be the same as:

 > as.logical(levels(factor(c("FALSE", "TRUE"))))
[1] FALSE  TRUE

according to the documentation? Did I miss something here?

 > sessionInfo()
R version 2.11.1 RC (2010-05-29 r52140)
x86_64-apple-darwin9.8.0

locale:
[1] C/UTF-8/C/C/C/C

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

Thanks,

Philippe
-- 
..............................................<°}))><........
  ) ) ) ) )
( ( ( ( (    Prof. Philippe Grosjean
  ) ) ) ) )
( ( ( ( (    Numerical Ecology of Aquatic Systems
  ) ) ) ) )   Mons University, Belgium
( ( ( ( (
..............................................................



More information about the R-help mailing list