number: Number formatters

Description Usage Arguments Value Examples

Description

number is a generic formatter for numeric values. addCommas is a shortcut for comma as separator for thousands, point for decimal. addSpaces is a shortcut for space as separator for thousands, point for decimal. percent a shortcut for percentages (value are multiplied by 100 and a compPercent returns the complement of 1, i.e. percent(1 - x).

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
number(x, accuracy = 1, multiplier = 1, prefix = "", suffix = "",
  big.mark = " ", decimal.mark = ".")

addCommas(x, accuracy = 1)

addSpaces(x, accuracy = 1)

percent(x, accuracy = 1)

compPercent(x, accuracy = 1)

Arguments

x

a numeric vector to format

accuracy

number to round to, NULL for automatic guess. [10 wll round to nearest 10, 1 will round to nearest integer, 0.1 to nearest 0.1, etc.]

multiplier

number to multiply by (e.g. for computing percentages or thousands)

prefix, suffix

Symbols to display before and after value

big.mark

character used between every 3 digits to separate thousands

decimal.mark

the character to be used to indicate the numeric decimal point

Value

a formatted character vector

Examples

1
2
3
4
5
6
v <- c(12.3, 4, 12345.789, 0.0002)
number(v)
addCommas(v, accuracy = 0.01)
p <- runif(10)
percent(p)
compPercent(p)

anilchalisey/juggleR documentation built on May 9, 2019, 4 a.m.