View source: R/utils_scibeautify.R
scibeautify | R Documentation |
Takes a number (or vector of numbers), and formats it in scientific notation as a string (or vector of strings) for use in printing. This function will format the number according to the specified number of significant digits, and using the specified format for scientific notation (e.g. x 10^n, eN, EN, etc). It will also correctly produce latex and html compatible strings.
scibeautify( .data, sig_digits = 3, output_format = c("unicode", "plain", "ascii", "html", "latex", "plotmath", "markdown"), sci_mode = c("auto", "on", "off"), sci_format = c("x", ".", "e", "E"), justify_mode = c("none", "l", "c", "r", "d", "lx", "cx", "rx", "dx"), pad_zeros = F, decimal_mark = ".", big_mark = ",", big_interval = 3, auto_ignore_int = T, nsmall = NULL, .cols = tidyr::everything(), .rows ) scibeautify.knit(.data, output_format = NULL, ...)
.data |
Numeric vector or dataframe. Non-numeric vectors will be coerced to numeric only if numeric values are preserved. |
sig_digits |
Number of significant digits. If NA or NULL, the input number is not changed. |
output_format |
(Optional) Output target. Can be one of "plain", "ascii" (same as plain), "unicode", "html", "latex", "plotmath", and "markdown". Default = "unicode". |
sci_mode |
(Optional) Can be one of "auto" (automatically choose whether scientific notation is used based on string length optimization), "on", or "off" (scientific notation always on or off). |
sci_format |
(Optional) Formatting of scientific notation. Can be one of "x" (times character), "." (center dot), "e" (lowercase e), "E" (uppercase E). Default = "x". |
justify_mode |
Mode to use for justifying a numbers. Can be "l" (left), "c" (center), "r" (right), or "d" (decimal). An "x" flag can be appended which will independently align the exponent portion of numbers in scientific notation, in addition to aligning the coefficient. Allowed values = |
pad_zeros |
Whether to add extra trailing zeros and/or a decimal to force number of significant digits (even if the original number did not have that many digits). Default = FALSE. |
decimal_mark |
Character to use as the decimal marker. |
big_mark |
If not blank, character to use in grouping every |
big_interval |
Number of digits between each |
auto_ignore_int |
(Optional) If the data (or column) is all integers, will not truncate non-significant digits and will not use scientific notation |
nsmall |
Forces output to have nsmall digits after the decimal. If there are fewer significant digits than total digits after including nsmall, the number of significant digits is increased. |
.cols |
Tidy selector for columns when |
.rows |
Vector of row numbers indicating where scibeautify should be applied. |
... |
Arguments passed on to |
scibeautify.knit
will choose the correct output format (latex or html) based on the knit options at runtime. By default, the function will check whether the knit output is html or graphic (LaTeX), and use the appropriate string codes.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.