Formats numbers in Brazilian style, with a decimal comma and a period as the thousands separator. Also formats currency and percentages.
Arguments
- x
Numeric vector.
- digits
Number of decimal places. Default is 0.
- percent
Logical. If
TRUE, multiplies by 100 and adds a percent sign.- currency
Logical. If
TRUE, formats as Brazilian reais (R$).- ...
Additional arguments passed to
scales::number().
See also
Other utilities:
has_insper_fonts(),
save_insper_plot()
Examples
# Basic number formatting
format_num_br(1234.56, digits = 2)
#> [1] "1.234,56"
# Currency formatting
format_num_br(1234.56, currency = TRUE, digits = 2)
#> [1] "R$ 1.234,56"
# Percentage formatting
format_num_br(0.1234, percent = TRUE, digits = 1)
#> [1] "12,3%"
format_num_br(0.1234, percent = TRUE, digits = 2)
#> [1] "12,34%"
