as.percent: Format Numbers as Percentages

Description Usage Arguments Details Value Examples

Description

Format numeric values as character strings with (optional) trailing percent sign.

Usage

1
as.percent(x, digits = 2, big.value = 1, percentSign = TRUE, sep = " ")

Arguments

x

vector of numeric values, typically in the range 0..'big.value'

digits

desired number of significant digits after the decimal point

big.value

largest expected value. All values get scaled so that 'big.value' would be returned as '100 %'

percentSign

logical, should the trailing percent sign be appended

sep

character string to insert between the numeric percentage and the percent sign.

Details

Used to represent arbitrary values as a percentage in character format, where the value to be represented as 100 % is given as 'big.value'. Implemented via 'formatC'.

Value

A character vector of the same length as 'x', scaled such that 'big.value' equals 100, with 'digits' significant digits and a trailing ' %' appended.

Examples

1
  as.percent( c( 7,21, 4), big.value=30, digits=2)

robertdouglasmorrison/DuffyTools documentation built on Dec. 14, 2018, 3:05 p.m.