# Suggestion for qqplot() improvement

**Peter Dalgaard BSA
**
p.dalgaard@biostat.ku.dk

*31 Aug 1999 16:56:48 +0200*

Martin Maechler <maechler@stat.math.ethz.ch> writes:
>* 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.
*>*
*>* I found:
*>*
*>* Trellis in S-plus has
*>* qqmath(formula, distribution = qnorm, f.value = ppoints, ...),
*>* for your example
*>* qqmath( ~ y, distribution = function(p) qt(p, df=5), ...)
*>*
*>* which is slightly more general (also works with panels, banking to 45
*>* deg,..) but quite a bit more complicated to use for non-sophisticated users.
*>*
*>* What should we do / would we want for R?
*
Lets see. "qqplot(qt, y, df=5)" would be tempting save for the
complexities of separating parts of ... intended for the quantile
function from those intended for the plotting.
We could "easily" have qqplot(y, distrib=qt(p,df=5)), here's a
simplified variant:
f <- function(y,distrib){
p <- ppoints(length(y))
x <- eval(eval(substitute(substitute(distrib)),list(p=p)))
qqplot(x,y,
xlab=deparse(substitute(distrib)),
ylab=deparse(substitute(y)))
}
f(rnorm(100), distrib=qt(p,df=2))
The form, e.g., qqplot(qt, y, df=5, lty=3) may not be *all* that hard
to set up. It's just necessary to manipulate the argument list,
somewhat along the lines of
g <- function(p,...){
l<-list(...)
m<-match(names(l), names(formals(qt)))
do.call("qt", c(list(p=p), l[!is.na(m)]))
}
which is just a long-winded version of qt, except that it strips off
unused arguments.
--
O__ ---- Peter Dalgaard Blegdamsvej 3
c/ /'_ --- Dept. of Biostatistics 2200 Cph. N
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk) FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._