Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

rrange

Robust Range using Boxplot 'Quartiles'


Description

Compute a robust range, i.e. the usual range() as long as there are no outliers, using the “whisker boundaries” of boxplot, i.e., boxplot.stats.

Usage

rrange(x, range=1, coef = 1.5, na.rm = TRUE)

Arguments

x

numeric vector the robust range of which shall be computed.

range

number for S compatibility; 1.5 * range is equivalent to coef.

coef

numeric multiplication factor definying the outlier boundary, see ‘Details’ below.

na.rm

logical indicating how NA values should be handled; they are simply dropped when na.rm = TRUE as by default.

Details

The robust range is really just what boxplot.stats(x, coef=coef) returns as the whisker boundaries. This is the most extreme values x[j] still inside median plus/minus coef * IQR.

Value

numeric vector c(m,M) with m <= M which is (not strictly) inside range(x) = c(min(x),max(x)).

Author(s)

Martin Maechler, 1990.

See Also

A more sophisticated robust range for (strongly) asymmetric data can be derived from the skewness adjusted boxplot statistics adjboxStats which is a generalization of boxplot.stats.

Examples

stopifnot(rrange(c(1:10,1000)) == c(1,10))

sfsmisc

Utilities from 'Seminar fuer Statistik' ETH Zurich

v1.1-11
GPL (>= 2)
Authors
Martin Maechler [aut, cre] (<https://orcid.org/0000-0002-8685-9910>), Werner Stahel [ctb] (Functions: compresid2way(), f.robftest(), last(), p.scales(), p.dnorm()), Andreas Ruckstuhl [ctb] (Functions: p.arrows(), p.profileTraces(), p.res.2x()), Christian Keller [ctb] (Functions: histBxp(), p.tachoPlot()), Kjetil Halvorsen [ctb] (Functions: KSd(), ecdf.ksCI()), Alain Hauser [ctb] (Functions: cairoSwd(), is.whole(), toLatex.numeric()*), Christoph Buser [ctb] (to function Duplicated()), Lorenz Gygax [ctb] (to function p.res.2fact()), Bill Venables [ctb] (Functions: empty.dimnames(), primes()), Tony Plate [ctb] (to inv.seq()), Isabelle Fl<fc>ckiger [ctb], Marcel Wolbers [ctb], Markus Keller [ctb], Sandrine Dudoit [ctb], Jane Fridlyand [ctb], Greg Snow [ctb] (to loessDemo()), Henrik Aa. Nielsen [ctb] (to loessDemo()), Vincent Carey [ctb], Ben Bolker [ctb], Philippe Grosjean [ctb], Fr<e9>d<e9>ric Ibanez [ctb], Caterina Savi [ctb], Charles Geyer [ctb], Jens Oehlschl<e4>gel [ctb]
Initial release
2021-04-03

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.