Suggestion for qqplot() improvement
Prof Brian D Ripley
ripley@stats.ox.ac.uk
Tue, 31 Aug 1999 17:24:18 +0100 (BST)
(Martin Maechler quoting Werner Stahel, I think)
> Maybe even
> qqplot(qt(ppoints(n), df=5), y,
> xlab='quantiles of t(* ,df=5)', ylab='data')
>
> WSt> and this could be shortened to
>
> WSt> qqplot(y, distribution='t', df=5)
>
> WSt> with an easy extension of the function.
Would qqplot(qt, y, df=5) or qqplot("t", y, df=5) with the following do
what you want? As plot warns about surplus arguments, I have removed them
from the ... in its call.
qqplot <- function (x, y, plot.it = TRUE, xlab = deparse(substitute(x)),
ylab = deparse(substitute(y)), ...)
{
xlab
sy <- sort(y)
leny <- length(sy)
dots <- list(...)
if(is.character(x)) x <- get(paste("q", x, sep=""))
if(is.function(x)) {
fn <- x
formals(fn) <- c(formals(fn), "..." = list(NULL))
sx <- fn(ppoints(leny), ...)
dots <- dots[!match(names(dots), names(formals(x)), FALSE)]
} else {
sx <- sort(x)
lenx <- length(sx)
if (leny < lenx) sx <- approx(1:lenx, sx, n = leny)$y
if (leny > lenx) sy <- approx(1:leny, sy, n = lenx)$y
}
if (plot.it)
do.call("plot", c(list(sx, sy, xlab = xlab, ylab = ylab), dots))
invisible(list(x = sx, y = sy))
}
--
Brian D. Ripley, ripley@stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272860 (secr)
Oxford OX1 3TG, UK Fax: +44 1865 272595
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._