report_percent: Round percentage values in standard way for reporting

View source: R/utils.R

report_percentR Documentation

Round percentage values in standard way for reporting

Description

Follows the advice from: http://adc.bmj.com/content/early/2015/04/15/archdischild-2014-307149 "Percentages: [Use] integers, or one decimal place for values under 10 Values over 90 Use two or more decimal places only if the range of values is less than 0.1

Usage

report_percent(x, round_90_to_one = FALSE, as_char = TRUE)

Arguments

x

Numeric vector of percentages.

round_90_to_one

Should values above 90 percent be reported to a single decimal place?

as_char

Should the result be returned as a character vector? Default 'TRUE'.

Value

Character vector of formatted percentages following these rounding rules

Examples

report_percent(c(2.5, 11.324, 95.898, 99.6))
report_percent(c(2.5, 11.324, 95.898, 99.6), round_90_to_one = TRUE)

bcgov/envreportutils documentation built on Feb. 1, 2024, 8:48 p.m.