getNDecimals {inTextSummaryTable}R Documentation

Get number of decimals for a specific vector.

Description

The number of decimals is extracted either:

Usage

getNDecimals(x, useRule = TRUE, rule = "1", useData = TRUE)

Arguments

x

Numeric vector.

useRule

Logical (TRUE by default), should the rule be applied?

rule

Character vector with rule to use to derive the number of parameters. Currently only: '1' is implemented.

  • '1': standard rule for the number of decimals for individual values for a continuous variable:

    • value < 1 ('very small values'): 3

    • value < 10: 2

    • value in [10, 1000[: 1

    • value >= 1000: 0

useData

Logical (TRUE by default), should the number of decimals be extracted based on the input data x?

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)

[Package inTextSummaryTable version 3.3.3 Index]