label_breaks: Label breaks

Description Usage Arguments Value Examples

View source: R/label_breaks.R

Description

Create two-sided labels from a sequence of values

Usage

1
label_breaks(breaks, exclusive = FALSE, add_Inf = TRUE, replace_Inf = TRUE)

Arguments

breaks

a vector with break values (Inf may be included)

exclusive

logical, indicating whether the right side of the label should display a mutually exclusive value with the left side of the following label. If FALSE (default), the labels display not mutually exclusive values (i.e. "1-10", 10-100", etc.). If TRUE the labels display mutually exclusive values (i.e. "1-9", 10-99", etc.).

add_Inf

logical, if TRUE (default), and if not already present, the value Inf is added as last value. If TRUE the length of the output vector is of the same input vector. If FALSE the length of the output vector is the length of the input vector -1.

replace_Inf

logical, if TRUE (default) the value Inf is replaced by a +.

Value

a vector of the same length of the input vector of length of the input vector - 1 if add_Inf is set as FALSE.

Examples

1
2
3
4
5
6
7
8
9
x <- c(1, 10, 100, Inf)
label_breaks(x)
label_breaks(x, exclusive = TRUE)
label_breaks(x, exclusive = FALSE, replace_Inf = TRUE)

y <- c(1, 10, 100)
label_breaks(y)
label_breaks(y, exclusive = TRUE) # same length of input vector
label_breaks(y, exclusive = FALSE, add_Inf = FALSE) # length of input vector - 1

epicentre-msf/covidutils documentation built on July 22, 2021, 1:03 p.m.