setRange | R Documentation |
setRange
makes sure that the range extracted from x
will be
valid for plotting.
setRange(x = NA, filter = TRUE, man = c(0, 0))
x |
A numeric vector. |
filter |
A logical vector that can be recycled if necessary to match the
length of |
man |
A numeric vector of length 2. |
Set range for a given numeric vector x
subsetted by a logical vector
filter
. If the subset contains any finite value, finite range of the
x
subset is returned. Else if x
contains any finite value,
finite range of x
is returned. When no finite value can be found in
x
, range is set manually (default man = c(0, 0)
).
If x
length is higher than filter
length, filter
will be
recycled.
range
.
## Not run:
(aa <- c(1, NA, Inf, -Inf, 3, NaN, rep(NA, 4)))
range(aa, finite = TRUE)
setRange(aa, TRUE) # same effect
# Useful when applying filters
aa[rep(c(FALSE, TRUE), each = 5)]
suppressWarnings(range(aa[rep(c(FALSE, TRUE), each = 5)], finite = TRUE))
setRange(aa, rep(c(FALSE, TRUE), each = 5)) # range taken from unfiltered 'aa'
setRange(aa[c(FALSE, TRUE)]) # No finite values in 'x', applies 'man' range
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.