format_num: Formatting numeric values

Description Usage Arguments Value Note Examples

View source: R/format_num.R

Description

Function to format an R object for pretty printing with a specified (k) number of decimal places. The function also allows really small p-values to be denoted as "p < 0.001" rather than "p = 0.000". Note that if p.value is set to TRUE, the minimum value of k allowed is 3. If k is set to less than 3, the function will ignore entered k value and use k = 3 instead.

Usage

1
format_num(x, k = 3L, p.value = FALSE, ...)

Arguments

x

A numeric value.

k

Number of digits after decimal point (should be an integer) (Default: k = 3L).

p.value

Decides whether the number is a p-value (Default: FALSE).

...

Currently ignored.

Value

Formatted numeric value.

Note

This function is not vectorized.

Examples

1
2
3
format_num(0.0000123, k = 2, p.value = TRUE)
format_num(0.008675, k = 2, p.value = TRUE)
format_num(0.003458, k = 3, p.value = FALSE)

ipmisc documentation built on May 7, 2021, 9:07 a.m.