AW: [Rd] Proposal: Generalizing unique() and duplicated()

Kaspar Pflugshaupt pflugshaupt@geobot.umnw.ethz.ch
Tue, 6 Feb 2001 16:51:34 +0100


On Tuesday 06 February 2001 13:49, Prof Brian Ripley wrote:

> Method dispatch is far from free (it is quite slow). Do we want to
> encumber unique() (a fast internal function) in this way?

That's a good argument. I did not know dispatch was such a problem in terms 
of speed. J. Oelschlägel suggested eliminating two dispatches by calling 

  return(duplicated.default(strvect)) 

instead of

  return(duplicated(strvect))

in both duplicated.matrix() and duplicated.data.frame().
But the speed gain, following your second argument, would probably be 
marginal. And the default methods would still get dispatched.

>
> There are better ways to do this if one is going to use C code:
> converting to character and comparing long strings are both expensive,

Since I cannot write C, this is not an option for me. I guess I'll take back 
my proposal and use the functions privately. I might publish them on r-help 
(in a non-dispatched form, not overloading the original functions), so others 
can use them as well.


Thanks for the feedback (I learned a lot)

Kaspar Pflugshaupt

----

Kaspar Pflugshaupt
Geobotanical Institute
ETH Zurich, Switzerland

http://www.geobot.umnw.ethz.ch
mailto:pflugshaupt@geobot.umnw.ethz.ch

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._