Skip to content

Commit

Permalink
mention relation to fivenum()
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.r-project.org/R/trunk@85232 00db46b3-68df-0310-9c12-caf00c1e9a41
  • Loading branch information
smeyer committed Sep 29, 2023
1 parent 2d3b9ac commit b22fcf0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 21 deletions.
21 changes: 14 additions & 7 deletions src/library/grDevices/man/boxplot.stats.Rd
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
% File src/library/grDevices/man/boxplot.stats.Rd
% Part of the R package, https://www.R-project.org
% Copyright 1995-2018 R Core Team
% Copyright 1995-2023 R Core Team
% Distributed under GPL 2 or later

\name{boxplot.stats}
Expand Down Expand Up @@ -28,18 +28,21 @@ boxplot.stats(x, coef = 1.5, do.conf = TRUE, do.out = TRUE)
but may be invoked separately.
}
\value{
List with named components as follows:
A list with named components as follows:

\item{stats}{a vector of length 5, containing the extreme of the
lower whisker, the lower \sQuote{hinge}, the median, the upper
\sQuote{hinge} and the extreme of the upper whisker.}
\sQuote{hinge} and the extreme of the upper whisker.
For \code{coef = 0}, this vector is identical to
\code{\link{fivenum}(x, na.rm = TRUE)}.}
\item{n}{the number of non-\code{NA} observations in the sample.}
\item{conf}{the lower and upper extremes of the \sQuote{notch}
(\code{if(do.conf)}). See the details.}
\item{out}{the values of any data points which lie beyond the
extremes of the whiskers (\code{if(do.out)}).}

Note that \code{$stats} and \code{$conf} are sorted in \emph{in}creasing
order, unlike S, and that \code{$n} and \code{$out} include any
Note that \code{stats} and \code{conf} are sorted in \emph{in}creasing
order, unlike S, and that \code{n} and \code{out} include any
\code{+- Inf} values.
}
\details{
Expand Down Expand Up @@ -96,10 +99,14 @@ x <- c(1:100, 1000)
(b2 <- boxplot.stats(x, do.conf = FALSE, do.out = FALSE))
stopifnot(b1 $ stats == b2 $ stats) # do.out = FALSE is still robust
boxplot.stats(x, coef = 3, do.conf = FALSE)

## no outlier treatment:
boxplot.stats(x, coef = 0)
(b3 <- boxplot.stats(x, coef = 0))
stopifnot(b3$stats == fivenum(x))

boxplot.stats(c(x, NA)) # slight change : n is 101
## missing values are ignored
stopifnot(identical(boxplot.stats(c(x, NA)), b1))
## ... infinite values are not:
(r <- boxplot.stats(c(x, -1:1/0)))
stopifnot(r$out == c(1000, -Inf, Inf))

Expand Down
20 changes: 6 additions & 14 deletions tests/Examples/grDevices-Ex.Rout.save
Original file line number Diff line number Diff line change
Expand Up @@ -459,8 +459,9 @@ NULL
$out
[1] 1000

>
> ## no outlier treatment:
> boxplot.stats(x, coef = 0)
> (b3 <- boxplot.stats(x, coef = 0))
$stats
[1] 1 26 51 76 1000

Expand All @@ -473,20 +474,11 @@ $conf
$out
numeric(0)

> stopifnot(b3$stats == fivenum(x))
>
> boxplot.stats(c(x, NA)) # slight change : n is 101
$stats
[1] 1 26 51 76 100

$n
[1] 101

$conf
[1] 43.13921 58.86079

$out
[1] 1000

> ## missing values are ignored
> stopifnot(identical(boxplot.stats(c(x, NA)), b1))
> ## ... infinite values are not:
> (r <- boxplot.stats(c(x, -1:1/0)))
$stats
[1] 1.0 25.5 51.0 76.5 100.0
Expand Down

0 comments on commit b22fcf0

Please sign in to comment.