
Last chance! 50% off unlimited learning
Sale ends in
Extends a numerical range by a small percentage, i.e., fraction, on both sides.
extendrange(x, r = range(x, na.rm = TRUE), f = 0.05)
numeric vector; not used if r
is specified.
numeric vector of length 2; defaults to the
range
of x
.
positive number(s) specifying the fraction by which the range should be
extended. If longer than one, f[1]
is used on the left, and
f[2]
on the right.
A numeric vector of length 2, r + c(-f1,f2) * diff(r)
, where
f1 is f[1]
and f2 is f[2]
or f
if it is of length
one.
range
; pretty
which can be
considered a sophisticated extension of extendrange
.
# NOT RUN {
x <- 1:5
(r <- range(x)) # 1 5
extendrange(x) # 0.8 5.2
extendrange(x, f= 0.01) # 0.96 5.04
## extend more to the right:
extendrange(x, f=c(.01,.03)) # 0.96 5.12
## Use 'r' if you have it already:
stopifnot(identical(extendrange(r = r),
extendrange(x)))
# }
Run the code above in your browser using DataLab