From berwin at maths.uwa.edu.au  Mon May 25 09:58:06 2009
From: berwin at maths.uwa.edu.au (Berwin A Turlach)
Date: Mon, 25 May 2009 15:58:06 +0800
Subject: [Rd] inconsistency in ?factor
In-Reply-To: <20090525070414.GA9602@cs.cas.cz>
References: <20090525070414.GA9602@cs.cas.cz>
Message-ID: <20090525155806.52c19122@absentia>

G'day Petr,

On Mon, 25 May 2009 09:04:14 +0200
Petr Savicky <savicky at cs.cas.cz> wrote:

> 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.

Well, the first statement is a remark on comparison in general while
the second statement is specific to "comparison operators and generic
methods".  There are other ways of comparing objects; note:

R> f1 <- factor(c("a", "b", "c", "c", "b", "a"), levels=c("a", "b", "c"))
R> f2 <- factor(c("a", "b", "c", "c", "b", "a"), levels=c("c", "b", "a"))
R> f1==f2
[1] TRUE TRUE TRUE TRUE TRUE TRUE
R> identical(f1,f2)
[1] FALSE
R> all.equal(f1,f2)
[1] "Attributes: < Component 2: 2 string mismatches >"

Just my 2c.

Cheers,

	Berwin

=========================== Full address =============================
Berwin A Turlach                            Tel.: +65 6516 4416 (secr)
Dept of Statistics and Applied Probability        +65 6516 6650 (self)
Faculty of Science                          FAX : +65 6872 3919       
National University of Singapore     
6 Science Drive 2, Blk S16, Level 7          e-mail: statba at nus.edu.sg
Singapore 117546                    http://www.stat.nus.edu.sg/~statba



[Rd] inconsistency in ?factor
Berwin A Turlach