[Rd] inconsistent handling of factor, character, and logical predictors in lm()

Abby Spurdle @purd|e@@ @end|ng |rom gm@||@com
Sun Sep 1 04:59:59 CEST 2019

> I think that this misses the point I was trying to make: lm() et al. treat logical variables as factors, not as numerical predictors.

I'm unenthusiastic about mapping TRUE to -1 and FALSE to 1, in the model matrix.
(I nearly got that back the front).

However, I've decided to agree with your original suggestion,
regarding $xlevels.
I think it should include the logical levels, if that's the right term...

However, I note that the output still won't be completely consistent.
Because one case leads to a logical vector and the other cases lead to
character vectors.

More information about the R-devel mailing list