[R] Fast R implementation of Gini mean difference

Thomas Lumley tlumley at u.washington.edu
Thu Apr 24 17:30:07 CEST 2003

On Thu, 24 Apr 2003, Andrew C. Ward wrote:

> Thank you to Deepayan Sarkar and Berwin Turlach for reminding me of
> the outer() function. A quick comparison shows outer() to be more than
> 10 times faster than the nested for() loop. The memory does blow out a
> bit (ran out of memory with a vector of 10000 elements), but it would
> be rare for me to calculate a mean difference for that many. Thanks
> again!

For larger vectors you could probably divide it up into blocks of a few
thousand and use outer inside a loop.

For really large vectors it would probably help to tabulate the data and
work with the unique values.


More information about the R-help mailing list