chop_fn {santoku} | R Documentation |
Chop using an existing function
Description
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 |
extend |
Logical. If |
left |
Logical. Left-closed or right-closed breaks? |
close_end |
Logical. Close last break at right? (If |
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_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))
}