From savicky at cs.cas.cz  Mon May 25 09:04:14 2009
From: savicky at cs.cas.cz (Petr Savicky)
Date: Mon, 25 May 2009 09:04:14 +0200
Subject: [Rd] inconsistency in ?factor
Message-ID: <20090525070414.GA9602@cs.cas.cz>

In the almost current development version (2009-05-22 r48594) and also in 
  https://svn.r-project.org/R/trunk/src/library/base/man/factor.Rd
?factor contains (compare the formulations marked by ^^^^^^)

\section{Warning}{
  The interpretation of a factor depends on both the codes and the
  \code{"levels"} attribute.  Be careful only to compare factors with
  the same set of levels (in the same order).  
                          ^^^^^^^^^^^^^^^^^

\section{Comparison operators and group generic methods}{
  ...

  Only \code{==} and \code{!=} can be used for factors: a factor can
  only be compared to another factor with an identical set of levels
  (not necessarily in the same ordering) or to a character vector.
   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

In the development version 2009-05-22 r48594, the latter formulation
"not necessarily in the same ordering" is correct.

  f1 <- factor(c("a", "b", "c", "c", "b", "a", "a"), levels=c("a", "b", "c"))
  f2 <- factor(c("a", "b", "c", "c", "b", "a", "c"), levels=c("c", "b", "a"))
  f1 == f2 # [1]  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE FALSE

The first formulation "Be careful to compare ... levels in the same order" may
be just a warning against a potential problem if the levels have different order,
however this is not clear.

Petr.



[Rd] inconsistency in ?factor
Petr Savicky