1#  File src/library/stats/R/qqplot.R
2#  Part of the R package, https://www.R-project.org
3#
4#  Copyright (C) 1995-2012 The R Core Team
5#
6#  This program is free software; you can redistribute it and/or modify
7#  it under the terms of the GNU General Public License as published by
8#  the Free Software Foundation; either version 2 of the License, or
9#  (at your option) any later version.
10#
11#  This program is distributed in the hope that it will be useful,
12#  but WITHOUT ANY WARRANTY; without even the implied warranty of
13#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14#  GNU General Public License for more details.
15#
16#  A copy of the GNU General Public License is available at
17#  https://www.R-project.org/Licenses/
18
19qqplot <- function(x, y, plot.it = TRUE,
20                   xlab = deparse1(substitute(x)),
21		   ylab = deparse1(substitute(y)), ...)
22{
23    sx <- sort(x)
24    sy <- sort(y)
25    lenx <- length(sx)
26    leny <- length(sy)
27    if( leny < lenx )
28	sx <- approx(1L:lenx, sx, n = leny)$y
29    if( leny > lenx )
30	sy <- approx(1L:leny, sy, n = lenx)$y
31    if(plot.it)
32	plot(sx, sy, xlab = xlab, ylab = ylab, ...)
33    invisible(list(x = sx, y = sy))
34}
35