decimal_dot: Evaluate an expression after forcing the decimal point to be...

View source: R/string.R

decimal_dotR Documentation

Evaluate an expression after forcing the decimal point to be a dot

Description

Sometimes it is necessary to use the dot character as the decimal separator. In R, this could be affected by two settings: the global option options(OutDec) and the LC_NUMERIC locale. This function sets the former to . and the latter to C before evaluating an expression, such as coercing a number to character.

Usage

decimal_dot(x)

Arguments

x

An expression.

Value

The value of x.

Examples

opts = options(OutDec = ",")
as.character(1.234)  # using ',' as the decimal separator
print(1.234)  # same
xfun::decimal_dot(as.character(1.234))  # using dot
xfun::decimal_dot(print(1.234))  # using dot
options(opts)

xfun documentation built on Nov. 1, 2024, 1:06 a.m.