str_humanize: Improve readability for humans

str_humanizeR Documentation

Improve readability for humans

Description

Improve readability for humans

Usage

str_humanize(x, ...)

## S3 method for class 'integer'
str_humanize(x, ...)

## S3 method for class 'numeric'
str_humanize(x, digits = NULL, tiny = NULL, zero = NULL, ...)

## S3 method for class 'tbl_df'
str_humanize(x, ...)

Arguments

x

an integer or numeric vector, or a tbl

...

(unused)

digits

number of digits to retain

tiny

what to print in place of tiny values (that round to zero, given the number of digits you've specified)

zero

what to print in place of actual zeros (that are EXACTLY zero)

Methods (by class)

  • integer: Do nothing to integers

  • numeric: Round real numbers to a given number of digits

  • tbl_df: Apply str_humanize(...) to each column in turn

Note

Per the help for round, the IEC 60559 ("round to the even digit") is used. See help(round) (look under the Details section).

Examples

x <- c(123456789.01, 0.996, 0.003, 0.007, 0.000001, 0)
str_humanize(x)
str_humanize(x, digits = 3)
str_humanize(x, digits = 3, tiny = "-")
str_humanize(x, digits = 2, tiny = "-", zero = "")


BAAQMD/strtools documentation built on May 3, 2024, 10:56 a.m.