Format Numeric Values as Dollar Amounts
dollarize.RdThis function formats numeric values as dollar amounts by rounding them to the nearest whole number, adding commas as thousand separators, and prefixing them with a dollar sign.
Examples
dollarize(1234567.89) # Returns "$1,234,568"
#> [1] "$1,234,568"
dollarize(c(1000, 2500.75, 999999.99)) # Returns c("$1,000", "$2,501", "$1,000,000")
#> [1] "$1,000" "$2,501" "$1,000,000"