cutf: cut a Numeric Variable into Intervals

Description Usage Arguments See Also Examples

View source: R/cutf.R

Description

This is a copy of the original base::cut.default function which uses the additional parameters format_fun and ... to apply custom formatting to the input. By default it behaves exactly like base::cut.default

Usage

1
2
cutf(x, breaks, labels = NULL, include.lowest = FALSE, right = TRUE,
  dig.lab = 3L, ordered_result = FALSE, format_fun = formatC, ...)

Arguments

x

a numeric vector which is to be converted to a factor by cutting.

breaks

either a numeric vector of two or more unique cut points or a single number (greater than or equal to 2) giving the number of intervals into which x is to be cut.

labels

labels for the levels of the resulting category. By default, labels are constructed using "(a,b]" interval notation. If labels = FALSE, simple integer codes are returned instead of a factor.

include.lowest

logical, indicating if an ‘x[i]’ equal to the lowest (or highest, for right = FALSE) ‘breaks’ value should be included.

right

logical, indicating if the intervals should be closed on the right (and open on the left) or vice versa.

dig.lab

integer which is used when labels are not given. It determines the number of digits used in formatting the break numbers.

ordered_result

logical: should the result be an ordered factor?

format_fun

formatting function

...

additional arguments passed to format_fun

See Also

base::cut

Examples

1
2
3
4
5
6
set.seed(1)
Z <- 1000*stats::rnorm(10000)
table(cutf(Z, c(-10005, -5000, 100, 0, 50, 10000)))
table(cutf(Z, c(-10005, -5000, 100, 0, 50, 10000), format_fun = format))
table(cutf(Z, c(-10005, -5000, 100, 0, 50, 10000), format_fun = signif2))
table(cutf(Z, c(-10005, -5000, 100, 0, 50, 10000), format_fun = format_metric))

moodymudskipper/cutr documentation built on Aug. 23, 2019, 7:15 p.m.