# Simple cases.
format_n_pct(n = 25, pct = 18.66)
format_n_pct(n = 25, pct = 18.66, .pct_digits = 2)
# If both `n` and `pct` are zero then the format is special, i.e. simply "0".
format_n_pct(n = 0, pct = 0)
# `format_n_pct()` is vectorised over `n` and `pct` but their length must
# match.
format_n_pct(n = c(20, 50), pct = c(10, 25))
# Missing values result in empty strings in the output.
format_n_pct(n = c(20, NA), pct = c(10, 25))
format_n_pct(n = c(20, 50), pct = c(10, NA))
Run the code above in your browser using DataLab