format_number: Format Number

Description Usage Arguments Value Examples

View source: R/format_number.R

Description

Formats numeric vectors, rounding values to a reasonable amount of digits, and inserting separators for large numbers. Useful for inserting inline numeric values in R Markdown.

Usage

1
format_number(x, round_digits = c(3, 2, 1, 0), large_num_sep = ",")

Arguments

x

A numeric vector

round_digits

The number of digits to round numbers at each cutoff (< 1, < 10, < 100, >= 100). Default value is 3, 2, 1, 0.

large_num_sep

A character to separate every three digits in large numbers. Default value is the American standard of using a comma (",").

Value

A character vector

Examples

1
2
format_number(pi * c(0.1, 1, 10, 100, 1000))
"0.314" "3.14"  "31.4"  "314"   "3,142"

tonofshell/cowpoke documentation built on June 12, 2020, 8:43 a.m.