format_number {schtools} | R Documentation |
Format human-readable numbers.
Description
Pastes formatted x
if numeric, otherwise x
unmodified.
Circumvents R's automatic scientific notation.
If a number is nearly whole (see is_nearly_whole()
), it is rounded to have
zero decimal places. Otherwise, numbers >= 1 are rounded to 1 decimal place;
numbers < 1 are rounded to have 2 significant digits.
Usage
format_number(x, nsmall = 1, signif_precise = 2)
Arguments
x |
inline code |
nsmall |
number of digits after the decimal point to round to when |
signif_precise |
number of significant digits to use when |
Value
formatted x
if numeric, otherwise x
unmodified.
Author(s)
Pat Schloss pschloss@umich.edu
Kelly Sovacool sovacool@umich.edu
Examples
format_number(0.0256)
format_number(.Machine$double.eps^0.5)
format_number(100000.08)
format_number(1.00000000000000000001)
format_number("this is a string")
[Package schtools version 0.4.1 Index]