getNDecimals | R Documentation |
The number of decimals is extracted either:
from specific implemented rule :
see getNDecimalsRule
for further details
from the data itself:
see getNDecimalsData
for further details
both criterias: in this case the minimum of the number of decimals for both criterias is used
getNDecimals(x, useRule = TRUE, rule = "1", useData = TRUE)
x |
Numeric vector. |
useRule |
Logical (TRUE by default), should the |
rule |
Character vector with rule to use to derive the number of parameters. Currently only: '1' is implemented.
|
useData |
Logical (TRUE by default), should the number of decimals
be extracted based on the input data |
Numeric vector of same length than x
with the number of decimals.
Laure Cougnaud
Other decimals:
formatPercentage()
,
getMaxNDecimals()
,
getMaxNDecimalsData()
,
getNDecimalsData()
x <- c(0.99, 5.679, 50.45, 1450)
# extract number of decimals based on data:
getNDecimals(x, useRule = FALSE, useData = TRUE)
# extract number of decimals based on pre-defined rule:
getNDecimals(x, useRule = TRUE, useData = FALSE)
# extract number of decimals based on both rules
# minimum of both is used (by default)
getNDecimals(x, useRule = TRUE, useData = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.