f: Format Digits

Description Usage Arguments Value See Also Examples

View source: R/f.R

Description

Remove leading zeros and standardize number of digits.

Usage

1
f(x, digits = getOption("digit_digits"), s, e)

Arguments

x

A vector of numbers (or string equivalents).

digits

The number of digits to use. Defaults to 3. Can be set globally via: options(digit_digits = n) where n is the number of digits beyond the decimal point to include.

s

A string to paste at the begining of the output from f.

e

A string to paste at the end of the output from f.

Value

Returns a string of publication ready digits.

See Also

p

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
f(c(0.0, 0, .2, -00.02, 1.122222, pi))
f(rnorm(10))
f(rnorm(20, 100, 200), 0)
f(c("-0.23", "0", ".23"))

## Percents
f(c(30, 33.45, .1), 1, e="%")

## Money
f(c(30, 33.45, .1), 2, s="$")

trinker/digit documentation built on May 27, 2017, 1:46 p.m.