[Rd] Re: unique()

Duncan Murdoch murdoch@stats.uwo.ca
Tue, 26 Nov 2002 09:29:09 -0500


On Tue, 26 Nov 2002 08:48:37 +0000 (GMT), Peter Green  wrote in
message <Pine.GSO.4.42.0211260844200.20783-100000@elios>:

>Hi, Duncan,
>
>Just a quick query/grumble.... I've just noticed that
>the operation of unique() on arrays changed somewhere
>between Rw1041 and 1061 - pity, as I had been relying on the old
>action (treat the argument as a vector) in some code.
>I didn't notice it mentioned in any 'changes' documents.

It was mentioned in the 1.6.0 news file:

>   o   duplicated() and unique() have methods for matrices and arrays
>       (based on ideas from Jens Oehlschlõgel).

There was a hint this was coming in the 1.4.0 news:

>    o   duplicated() and unique() are now generic functions with
>        methods for data frames (as well as atomic vectors).

You can get the old behaviour for arrays by unique(as.vector(x))
instead of unique(x), as you've probably figured out.

I wonder if there could be a mechanism that would warn about things
like this?  E.g. instead of a flat news file that you have to read all
through, maybe a database of changes, and a tool that could look
through your code and spot things whose usage had changed?
I think maintaining the accuracy of the database would be hard.

Duncan