[R] How to get warning about implicit factor to integer coercion?

WB Kloke wb at ifado.de
Tue Feb 15 08:25:56 CET 2011


 <Bill.Venables <at> csiro.au> writes:

> 
> Your complaint is based on what you think a factor should be rather than what
it actually is andhow it works. 
> The trick with R (BTW I think it's version 2.12.x rather than 12.x at this
stage...) is learning to work
> *with* it as it is rather than making it work the way you would like it to do.
> 
> Factors are a bit tricky.  The are numeric objects, even if arithmetic is
inhibited.

Sorry. You didn't get my point. I know how factors work (see my reply to Ista).
I don't even want to change the general behaviour (though I am convinced that it
is very ill designed). I just want to be able to change some option to generate
a warning in a case of probable unintended use, for those poor souls beginning
to use R (or S-plus either).

As I explained to Ista, the error is very likely to happen in very common
situations, without any warning at any stage. Sometimes warnings are generated
by R functions (such as when strings are converted to factors implicitly for
lm() ), but most of those warnings are spurious.

Of course, I shall teach my students of R to be afraid of such errors, but it is
clearly embarassing to explain the reason.



More information about the R-help mailing list