| fmt_range | R Documentation |
A function to calculate and format a numeric range.
fmt_range(x, format = "%s", sep = "-")
x |
The input data vector or data frame column. |
format |
A formatting string suitable for input into the
|
sep |
The token used to separate the minimum and maximum range values. Default value is a hyphen ("-"). |
This function calculates a range using the Base R range
function, and then formats the output using sprintf.
You may control the format using the format parameter. Any NA values
in the input data are ignored. Results are returned as a character vector.
The formatted range values.
Other helpers:
fmt_cnt_pct(),
fmt_mean_sd(),
fmt_median(),
fmt_n(),
fmt_quantile_range()
# Create example vector
v1 <- c(4.3, 3.7, 8.7, 6.1, 9.2, 5.6, NA, 0.7, 7.8, 4.9)
# Format range
fmt_range(v1)
# "0.7 - 9.2"
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.