From deepayan.sarkar at gmail.com  Thu Mar  2 03:02:13 2006
From: deepayan.sarkar at gmail.com (deepayan.sarkar@gmail.com)
Date: Thu,  2 Mar 2006 03:02:13 +0100 (CET)
Subject: [Rd] Bug/Wishlist: 'partial' in 'sort' and 'quantile' (PR#8650)
Message-ID: <20060302020213.9CCC93FBD1@slim.kubism.ku.dk>

Hi,

This is essentially a reposting of

http://tolstoy.newcastle.edu.au/R/devel/05/11/3305.html

which had no responses, and the behaviour reported there persists in
r-devel as of yesterday.

(1) sort() with non-null partial

> x = rnorm(100000)
> keep = as.integer(ppoints(10000) * 100000)
> system.time(sort(x))
[1] 0.05 0.00 0.04 0.00 0.00
> system.time(sort(x, partial = keep))
[1] 52.04  0.02 52.08  0.00  0.00

This is perhaps not strictly a bug, but taking approximately 1000
times longer to do a subset of the work seems pointless at best.

(2) quantile.default() always calls sort() with a non-null partial
argument. Consequently,

> system.time(quantile(x, ppoints(10000)))
[1] 88.82  0.05 88.90  0.00  0.00

There's no way around this except by writing a custom version of
quantile. lattice currently does this, giving

> system.time(lattice:::fast.quantile(x, ppoints(10000)))
[1] 0.07 0.01 0.08 0.00 0.00

Which brings me to my wishlist request: if (1) cannot be fixed easily,
could quantile.default() at least have an optional argument that can
be used to disable partial sorting?

> sessionInfo()
Version 2.3.0 Under development (unstable) (2006-02-28 r37448)
x86_64-unknown-linux-gnu

attached base packages:
[1] "methods"   "stats"     "graphics"  "grDevices" "utils"     "datasets"
[7] "base"

Deepayan
--
http://www.stat.wisc.edu/~deepayan/



[Rd] Bug/Wishlist: 'partial' in 'sort' and 'quantile' (PR#8650)
deepayan.sarkar@gmail.com