R/radiant.R
format_nr.RdFormat a number with a specified number of decimal places, thousand sep, and a symbol
format_nr(x, sym = "", dec = 2, perc = FALSE, mark = ",", na.rm = TRUE, ...)
| x | Number or vector |
|---|---|
| sym | Symbol to use |
| dec | Number of decimals to show |
| perc | Display number as a percentage |
| mark | Thousand separator |
| na.rm | Remove missing values |
| ... | Additional arguments passed to |
Character (vector) in the desired format
format_nr(2000, "$")#> [1] "$2,000.00"format_nr(2000, dec = 4)#> [1] "2,000.0000"format_nr(.05, perc = TRUE)#> [1] "5.00%"#> [1] "10.00%" "99.00%"#> [1] "10.00%" "99.00%"#> [1] "$1" "$2" "$3" "$4" "$5" "$6" "$7" "$8" "$9" "$10"#> [1] "1.00" "1.90" "1.01" "1.00"#> [1] "1" "1.9" "1.01" "1"format_nr(NA)#> [1] ""format_nr(NULL)#> [1] ""