Learn R Programming

inTextSummaryTable (version 3.3.2)

getMaxNDecimals: Get maximum number of decimals in a variable, based on pre-defined rule and/or data.

Description

The function getNDecimals) extracts the number of decimals in a specific variable.

Usage

getMaxNDecimals(x, ...)

Value

Integer with maximum number of decimals in a character vector.

Arguments

x

Numeric vector.

...

Any parameters for the getNDecimals function.

Author

Laure Cougnaud

See Also

Other decimals: formatPercentage(), getMaxNDecimalsData(), getNDecimals(), getNDecimalsData()

Examples

Run this code
x <- c(0.99, 5.679, 50.45, 1450)
# extract max number of decimals based on data:
getMaxNDecimals(x, useRule = FALSE, useData = TRUE)
# extract max number of decimals based on pre-defined rule:
getMaxNDecimals(x, useRule = TRUE, useData = FALSE)
# extract max number of decimals based on both rules
# minimum of both is used (by default)
getMaxNDecimals(x, useRule = TRUE, useData = TRUE)

Run the code above in your browser using DataLab