It's not a matter of unordered & ordered factors, but ordered factors
and Dates (as the warning says)
I can see at least one ambiguity -- should comparison be made from the
level or the internal code -- so the warning makes sense to me (though
an error might make even more sense). Generally, for factors that
correspond to non-Date quantities, the comparison likely isn't well
defined.
How would you resolve this comparison in general?
Michael
On Sat, Feb 18, 2012 at 3:08 PM, johnmark <johnmark.agosta at gmail.com>
wrote:> ?This error occurs because the "==" comparison operator
doesn't allow
> comparison of ordered and normal factors:
>
> /df[df5$close_quarter == as.Date("2011-02-01"),]/
> Warning message:
> In /`[.data.frame`(df, df$close_quarter ==
as.Date("2011-02-01")/, ?:
> ?Incompatible methods ("Ops.ordered", "Ops.Date") for
"=="
>
> Why should this be a problem -- Isn't this being overly cautious? ?Can
> anyone think of a case where coercing the ordered factor to a normal factor
> for comparisons of == would do the wrong thing?
>
> Perhaps this is a question for the developer's section.
>
> Cheers -john mark agosta
>
>
>
> --
> View this message in context:
http://r.789695.n4.nabble.com/Finicky-factor-comparison-operators-tp4400377p4400377.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.