write_int: Format an interval for display

Description Usage Arguments Details Value Examples

View source: R/write_int.R

Description

write_int formats a numeric input into an interval to be printed, e.g., in an RMarkdown document.

Usage

1
write_int(x, delim = "(", digits = 2)

Arguments

x

A length-2 numeric vector consisting of the endpoints of the interval or an n-row by 2-column matrix of endpoints.

delim

The bracket delimiters to surround the interval. Must be either a round bracket, square bracket, curly bracket, or angled bracket.

digits

Number of digits to round to (default to 2). Will keep trailing zeros.

Details

If a matrix is provided, the values in each row will be used to create a formatted interval.

Value

Returns a character string of the form "(x[1], x[2])" (or supplied bracket delimiter).

Examples

1
2
write_int(x=c(1.2, 2.345))
write_int(x=c(1.2, 2.345), delim='[')

tldr documentation built on July 28, 2021, 5:09 p.m.