Usage
h_get_format_threshold(digits = 2L)
h_format_threshold(x, digits = 2L)
format_extreme_values(digits = 2L)
format_extreme_values_ci(digits = 2L)
Details
For each input, apply a format to the specified number of digits
. If the value is
below a threshold, it returns "<0.01" e.g. if the number of digits
is 2. If the value is
above a threshold, it returns ">999.99" e.g. if the number of digits
is 2.
If it is zero, then returns "0.00".
Functions
h_get_format_threshold()
: Internal helper function to calculate the threshold and create formatted strings used in Formatting Functions. Returns a list with elementsthreshold
andformat_string
.h_format_threshold()
: Internal helper function to apply a threshold format to a value. Creates a formatted string to be used in Formatting Functions.format_extreme_values()
: Create Formatting Function for a single extreme value.format_extreme_values_ci()
: Create Formatting Function for extreme values part of a confidence interval. Values are formatted as e.g. "(xx.xx, xx.xx)" if if the number ofdigits
is 2.
See also
Other formatting functions:
format_count_fraction()
,
format_fraction_threshold()
,
format_fraction()
,
formatting_functions
Examples
h_get_format_threshold(2L)
#> $threshold
#> low high
#> 0.01 999.99
#>
#> $format_string
#> low high
#> "<0.01" ">999.99"
#>
h_format_threshold(0.001)
#> [1] "<0.01"
h_format_threshold(1000)
#> [1] ">999.99"
format_fun <- format_extreme_values(2L)
format_fun(x = 0.127)
#> [1] "0.13"
format_fun(x = Inf)
#> [1] ">999.99"
format_fun(x = 0)
#> [1] "0.00"
format_fun(x = 0.009)
#> [1] "<0.01"
format_fun <- format_extreme_values_ci(2L)
format_fun(x = c(0.127, Inf))
#> [1] "(0.13, >999.99)"
format_fun(x = c(0, 0.009))
#> [1] "(0.00, <0.01)"