getNDecimals {inTextSummaryTable} | R Documentation |
Get number of decimals for a specific vector.
Description
The number of decimals is extracted either:
from specific implemented rule : see
getNDecimalsRule
for further detailsfrom the data itself: see
getNDecimalsData
for further detailsboth criterias: in this case the minimum of the number of decimals for both criterias is used
Usage
getNDecimals(x, useRule = TRUE, rule = "1", useData = TRUE)
Arguments
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 |
Value
Numeric vector of same length than x
with the number of decimals.
Author(s)
Laure Cougnaud
See Also
Other decimals:
formatPercentage()
,
getMaxNDecimals()
,
getMaxNDecimalsData()
,
getNDecimalsData()
Examples
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)