View source: R/formatNumerics.R
| formatNumerics | R Documentation |
Render numeric values of an object as character using the specified format:
If object is a data.frame or a list, formatNumerics applies on each of its fields
If object is of type character or integer, formatNumerics renders the values as is
If object is of type numeric, formatNumerics applies the defined format
formatNumerics( object, digits = ospsuiteUtilsEnv$formatNumericsDigits, scientific = FALSE )
object |
An R object such as a list, a data.frame, character or numeric values. |
digits |
Number of decimal digits to render |
scientific |
Logical value defining if scientific writing is rendered |
Numeric values are rendered as character values. If object is a
data.frame or a list, a data.frame or list is returned with numeric values
rendered as character values.
# Format array of numeric values
formatNumerics(log(c(12, 15, 0.3)), digits = 1, scientific = TRUE)
# Format a data.frame
x <- data.frame(parameter = c("a", "b", "c"), value = c(1, 110.4, 6.666))
formatNumerics(x, digits = 2, scientific = FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.