[Rd] unique turns ordered into factor (PR#2591)

maechler@stat.math.ethz.ch maechler@stat.math.ethz.ch
Fri Feb 28 16:14:02 2003


>>>>> "PD" == p dalgaard <p.dalgaard@biostat.ku.dk>
>>>>>     on Fri, 28 Feb 2003 15:58:02 +0100 (MET) writes:

    PD> [reported originally by Christoffer Tornĝe]
    >> f <- ordered(month.name)
    >> f
    PD> [1] January   February  March     April     May       June      July
    PD> [8] August    September October   November  December
    PD> 12 Levels: April < August < December < February < January < July < ... < September

    >> unique(f)
    PD> [1] January   February  March     April     May       June      July
    PD> [8] August    September October   November  December
    PD> 12 Levels: April August December February January July June March ... September

    PD> this causes trouble in the internals of panel.superpose if the groups
    PD> argument is an ordered factor. In that case

    PD> id <- (groups[subscripts] == vals[i])

    PD> gives off the warning

    PD> Incompatible methods ("Ops.ordered", "Ops.factor") for "=="

    PD> S-PLUS (6.0 at least) does not do this, so I assume the fix is to
    PD> modify unique.default in the obvious way.

I think it's a clear bug (independently of other implementations ..)
Maybe it would be a bit cleaner to write an unique.factor().
The current unique.default() stems from the pre-method time,
i.e., when it was just unique().

    PD> [Still present in the development sources]

Martin