set_range: Set Range for Plotting

Description Usage Arguments Details See Also Examples

Description

Ensure that the range extracted from x is valid for plotting.

Usage

1
set_range(x = NA, filter = TRUE, man = c(0, 0), mad_adj = FALSE)

Arguments

x

A numeric vector.

filter

A logical vector that can be recycled if necessary to match the length of x.

man

A numeric vector of length 2.

Details

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.

See Also

range.

Examples

1
2
3
4
5
6
7
8
(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(F, T), each = 5)]
suppressWarnings(range(aa[rep(c(F, T), each = 5)], finite = TRUE))
setRange(aa, rep(c(F, T), each = 5)) # range taken from unfiltered 'aa'
setRange(aa[c(FALSE, TRUE)]) # No finite values in 'x', applies 'man' range

grahamstewart12/tidyflux documentation built on June 4, 2019, 7:44 a.m.