Currency formatter: round to nearest penny and display pounds sign.
Source:R/pounds.R
pounds_format.RdThe returned function will format a vector of values as currency.
Values are rounded to the nearest penny, and pennies are displayed if
any of the values has a non-zero pennies and the largest value is less
than largest_with_penny which by default is 100000.
Arguments
- x
a numeric vector to format
- largest_with_penny
the value that all values of
xmust be less than in order for the cents to be displayed
See also
Other helper:
CJ.dt(),
convertToXML(),
generatePDF(),
sanitise(),
thousands_format(),
wordwrap()
Examples
pounds_format()(c(100, 0.23, 1.456565, 2e3))
#> [1] "£100.00" "£0.23" "£1.46" "£2,000.00"
pounds_format()(c(1:10 * 10))
#> [1] "£10" "£20" "£30" "£40" "£50" "£60" "£70" "£80" "£90" "£100"
pounds(c(100, 0.23, 1.456565, 2e3))
#> [1] "£100.00" "£0.23" "£1.46" "£2,000.00"
pounds(c(1:10 * 10))
#> [1] "£10" "£20" "£30" "£40" "£50" "£60" "£70" "£80" "£90" "£100"
pounds(10^(1:8))
#> [1] "£10" "£100" "£1,000" "£10,000" "£100,000"
#> [6] "£1,000,000" "£10,000,000" "£100,000,000"