chop_fn() is a convenience wrapper: chop_fn(x, foo, ...)
is the same as chop(x, foo(x, ...)).
Usage
chop_fn(
x,
fn,
...,
extend = NULL,
left = TRUE,
close_end = TRUE,
raw = NULL,
drop = TRUE
)
brk_fn(fn, ...)
tab_fn(
x,
fn,
...,
extend = NULL,
left = TRUE,
close_end = TRUE,
raw = NULL,
drop = TRUE
)Arguments
- x
A vector.
- fn
A function which returns a numeric vector of breaks.
- ...
Further arguments to
fn- extend
Logical. If
TRUE, always extend breaks to+/-Inf. IfNULL, extend breaks tomin(x)and/ormax(x)only if necessary. IfFALSE, never extend.- left
Logical. Left-closed or right-closed breaks?
- close_end
Logical. Close last break at right? (If
leftisFALSE, close first break at left?)- raw
Logical. Use raw values in labels?
- drop
Logical. Drop unused levels from the result?
Value
chop_* functions return a factor of the same length as x.
brk_* functions return a function to create breaks.
tab_* functions return a contingency table().
See also
Other chopping functions:
chop(),
chop_equally(),
chop_evenly(),
chop_mean_sd(),
chop_n(),
chop_proportions(),
chop_quantiles(),
chop_spikes(),
chop_width(),
fillet()
Examples
if (requireNamespace("scales")) {
chop_fn(rlnorm(10), scales::breaks_log(5))
# same as
# x <- rlnorm(10)
# chop(x, scales::breaks_log(5)(x))
}
#> Loading required namespace: scales
#> [1] [0.1, 0.3) [1, 3) [0.03, 0.1) [0.3, 1) [1, 3) [3, 10]
#> [7] [0.1, 0.3) [0.3, 1) [0.3, 1) [0.3, 1)
#> Levels: [0.03, 0.1) [0.1, 0.3) [0.3, 1) [1, 3) [3, 10]
