From Kurt.Hornik at wu.ac.at  Sat Jan  8 08:54:26 2011
From: Kurt.Hornik at wu.ac.at (Kurt Hornik)
Date: Sat, 8 Jan 2011 08:54:26 +0100
Subject: [Rd] Minimum of an ordered factor
In-Reply-To: <19750.61839.60744.481983@lynne.math.ethz.ch>
References: <F54EF8F1B477CF448729593FE421F6464A22AE@HQVEVE0032.nestle.com>
	<19748.36291.498450.670163@lynne.math.ethz.ch>
	<19749.37073.506112.61897@fangorn.hornik.net>
	<F54EF8F1B477CF448729593FE421F6464A2377@HQVEVE0032.nestle.com>
	<19750.61839.60744.481983@lynne.math.ethz.ch>
Message-ID: <19752.6194.611459.498155@fangorn.hornik.net>

>>>>> Martin Maechler writes:

>>>>> "TTLAM" == Thaler, Thorn, LAUSANNE, Applied Mathematics <Thorn.Thaler at rdls.nestle.com>
>>>>>     on Thu, 6 Jan 2011 15:37:01 +0100 writes:

TTLAM> Kurt Hornik writes
>>> >> if (!all(sapply(args, is.ordered)) ||
>>> >> !all(sapply(level.list, identical, y = level.set))) {
>>> 
>>> I think it would be better to use something like
>>> 
>>> ll <- lapply(args, levels)
>>> 
>>> !all(sapply(ll, identical, ll[[1L]]))
>>> 
>>> [using union() is not quite right]

TTLAM> Yes definitely. This line is in fact just a relic from a previous idea I
TTLAM> had.
 
> I have now committed the amended proposal (rev 53925);
> thank you for the feedbacks..


>>> The general comment is that if we support this I don't see why we
>>> should
>>> not also support c.ordered (and in fact also c.factor) with the same
>>> restrictions (identical level sequences for ordered and level sets for
>>> factors).  We already have Ops.factor and Ops.ordered using the same
>>> principle afaic.

> Yes, I think, too.

>>> If we add c.ordered, we should be able to encapsulate the identity of
>>> levels testing into this, and simply use
>>> 
>>> x <- c(...)
>>> 
>>> and then call .Generic on the codes of x etc.

TTLAM> Sounds reasonable. Ack.

> Yes, adding c.factor() and c.ordered() seems reasonable in
> principle.
> However, S and R now have a more than 20 year old history of
> silently coercing factors to there integer codes with c(),
> that I'm not yet sure we can do this without breaking too much
> code [[and I am pretty sure this topic has been discusses before]].

Yes, of course.  But then we just made another backwards incompatible
change, and

R> c(ordered(1 : 3), ordered(4 : 6))
[1] 1 2 3 1 2 3

seems more like a bug to me :-)

> I think we should start discussing the issue in a new thread
> with proper Subject explicitly mention "c()" or
> "c.factor"/"c.ordered".

Yes!

Best
-k

> Martin



TTLAM> BR Thorn

TTLAM> ______________________________________________
TTLAM> R-devel at r-project.org mailing list
TTLAM> https://stat.ethz.ch/mailman/listinfo/r-devel



[Rd] Minimum of an ordered factor
Kurt Hornik