View source: R/to_scientific.R
to_scientific | R Documentation |
This function converts a vector of numbers to formatted scientific notation
expressions. It is called by label_sci()
to convert the
ggplot2
scale function labels to scientific format.
to_scientific( x, digits = 2, max_cut = 10^5, min_cut = 10^-3, common = FALSE, factor = NULL, trailing = TRUE, units = NULL )
x |
Numeric vector, gives numbers to convert to scientific notation |
digits |
Number of significant figures to display in the converted output |
max_cut |
Above this number, values will be converted into scientific format (inclusive) |
min_cut |
Below this number, values will be converted into scientific format (exclusive) |
common |
Should the formatted numbers share a common exponential factor? |
factor |
Provides a value for the common exponential factor; if |
trailing |
Should trailing zeros be included in the formatted number? |
units |
If provided, adds units to the converted output |
An expression containing the input numbers in scientific format
a <- c(NA, 10657, 0.00187, 0.0005, 102, 0) to_scientific(a)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.