h_format_number: Conditional Formatting Using C-style Formats

Description Usage Arguments Value Note Examples

View source: R/helpers.R

Description

[Experimental]

This helper function conditionally formats a number with formatC() function using "E" format and specific number of digits as given by the user. A number is formatted if and only if its absolute value is less than 0.001 or greater than 10000. Otherwise, the number is not formatted. Additionally, custom prefix or suffix can be appended to character string with formatted number, so that the changes are marked.

Usage

1
h_format_number(x, digits = 5, prefix = "", suffix = "")

Arguments

x

(number)
a number to be formatted.

digits

(function)
the desired number of significant digits.

prefix

(string)
a prefix to be added in front of the formatted number.

suffix

(string)
a suffix to be appended after the formatted number.

Value

Either formatted x as string or unchanged x if the formatting condition is not met.

Note

This function was primarily designed as a helper for h_jags_write_model() function.

Examples

1
2
h_format_number(50000)
h_format_number(50000, prefix = "P", suffix = "S")

0liver0815/onc-crmpack-test documentation built on Feb. 19, 2022, 12:25 a.m.