f_dollar: Format Dollars

Description Usage Arguments Value See Also Examples

View source: R/f_dollar.R

Description

f_dollar - A wrapper for f_num that formats dollar values as labeled dollars.

Usage

1
2
3
f_dollar(x, leading_zero = TRUE, digits = 2, p = "$", ...)

ff_dollar(...)

Arguments

x

A vector of values.

leading_zero

logical. If TRUE a leading zero will be added to values from 0 up to 1.

digits

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

p

A string to paste at the beginning of the output from f_num. Defaults to dollar sign. This could be useful, for example, to turn a single dolar sign into an escaped version for LaTeX output.

...

Other values passed to f_num.

Value

Returns a string of publication ready digits.

See Also

f_num

Examples

1
2
3
4
5
6
7
f_dollar(c(30, 33.45, .1))
## Not run: 
library(dplyr)

f_dollar(c(0.0, 0, .2, -00.02, 1122222, pi)) %>% f_comma()

## End(Not run)

Example output

[1] "$30.00" "$33.45" "$0.10" 

Attaching package:dplyrThe following object is masked frompackage:numform:

    collapse

The following objects are masked frompackage:stats:

    filter, lag

The following objects are masked frompackage:base:

    intersect, setdiff, setequal, union

[1] "$0.00"         "$0.00"         "$0.20"         "$-.02"        
[5] "$1,122,222.00" "$3.14"        

numform documentation built on Oct. 10, 2021, 1:10 a.m.