format.interval: Format intervals for printing

View source: R/format.interval.R

format.intervalR Documentation

Format intervals for printing

Description

format.interval prepares intervals for results printing.

Usage

## S3 method for class 'interval'
format(interval, digits = 2)

Arguments

interval

Must be a vector of two values. Values can be either numeric or character.

digits

Number of fixed digits, after decimal point.

Details

This function formats a given interval with the given number of decimal digits. interval is always assumed to be a two valued vector of double. If there is a percent sign in any of interval values, it is removed prior to formatting by format.float.

Value

Returns a character value.

Author(s)

Felipe Figueiredo

Examples

format.interval(c(1.756, 1.823))
# format.interval(1.5, 1) # error: 1.5 is not an interval

# Input is character
format.interval(c("1.756", "1.823"))

# Input is percentage
format.interval(c("10%", "15%"), 1)


philsf/philsfmisc documentation built on April 11, 2022, 9:04 p.m.