fmt_leading_zero: Format numbers to remove leading zeros

View source: R/formatters.R

fmt_leading_zeroR Documentation

Format numbers to remove leading zeros

Description

Format numbers to remove leading zeros

Usage

fmt_leading_zero(xs)

Arguments

xs

a vector of numbers or a character vector representing numbers

Details

APA format says that values that are bounded between [-1, 1] should not be formatted with a leading zero. Common examples would be correlations, proportions, probabilities and p-values. Why print the digit if it's almost never used?

Zeros are printed to match the precision of the most precise number. For example, c(0, 0.111) becomes c(.000, .111)

Value

the vector with leading zeros removed. This function returns a warning if any of the values have an absolute value greater than 1.

Examples

fmt_leading_zero(c(0, 0.111))
fmt_leading_zero(c(0.99, -0.9, -0.0))

tjmahr/printy documentation built on March 4, 2024, 1:25 a.m.