pretty_cuts: Pretty Cuts

Description Usage Arguments Details Value Acknowledgements Examples

View source: R/pretty-cuts.R

Description

Function removing set notation used by cut or by cut2.

Usage

1
pretty_cuts(cut_str, only_cuts = FALSE)

Arguments

cut_str

A character or factor vector produced by cut or by cut2 or a similar function. The set values have to be expressed as integer strings.

only_cuts

A logical, defaults to FALSE. If TRUE the function will return only cut boundaries. For FALSE the function replaces each value with modified set value.

Details

For a factor generated by cut2 "[2057,2652)", "[2652,3092)", "..." the function will return a character vector "2057 - 2651", "2652 - 3091", "..."

Value

A character vector.

Acknowledgements

The following function was referenced on Stacks Overflow on a number of occasions, in reference to obtaining nicer cuts, improving function performance and reducing small groups. The linked discussion provide a more comprehensive solutions than the function offered in this package.

Examples

1
2
set.seed(123)
pretty_cuts(cut(x = runif(n = 1e3, min = 1, 1e4), breaks = 5))

konradedgar/KEmisc documentation built on April 15, 2021, 1:50 p.m.