ddSci | R Documentation |
2 Decimal places, otherwise scientific notation
ddSci(x, decimal.places = 2, hi = 1e+06, asNumeric = FALSE)
x |
Vector of numbers |
decimal.places |
Integer: Return this many decimal places. Default = 2 |
hi |
Float: Threshold at or above which scientific notation is used. Default = 1e06 |
asNumeric |
Logical: If TRUE, convert to numeric before returning. Default = FALSE.
This will not force all numbers to print 2 decimal places. For example:
1.2035 becomes "1.20" if |
Numbers will be formatted to 2 decimal places, unless this results in 0.00 (e.g. if input was .0032),
in which case they will be converted to scientific notation with 2 significant figures.
ddSci
will return 0.00
if the input is exactly zero.
This function can be used to format numbers in plots, on the console, in logs, etc.
Formatted number
E.D. Gennatas
x <- .34876549
ddSci(x)
# "0.35"
x <- .00000000457823
ddSci(x)
# "4.6e-09"
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.