Learn R Programming

tldr (version 0.3.0)

write_int: Format an interval for display

Description

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

Usage

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

Value

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

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.

Examples

Run this code
write_int(x=c(1.2, 2.345))
write_int(x=c(1.2, 2.345), delim='[')

Run the code above in your browser using DataLab