| 1 |
% Generated by roxygen2: do not edit by hand |
| 2 |
% Please edit documentation in R/string.R |
| 3 |
\name{decimal_dot} |
| 4 |
\alias{decimal_dot} |
| 5 |
\title{Evaluate an expression after forcing the decimal point to be a dot} |
| 6 |
\usage{ |
| 7 |
decimal_dot(x) |
| 8 |
} |
| 9 |
\arguments{ |
| 10 |
\item{x}{An expression.} |
| 11 |
} |
| 12 |
\value{ |
| 13 |
The value of \code{x}. |
| 14 |
} |
| 15 |
\description{ |
| 16 |
Sometimes it is necessary to use the dot character as the decimal separator. |
| 17 |
In R, this could be affected by two settings: the global option |
| 18 |
\code{options(OutDec)} and the \code{LC_NUMERIC} locale. This function sets the former |
| 19 |
to \code{.} and the latter to \code{C} before evaluating an expression, such as |
| 20 |
coercing a number to character. |
| 21 |
} |
| 22 |
\examples{ |
| 23 |
opts = options(OutDec = ",") |
| 24 |
as.character(1.234) # using ',' as the decimal separator |
| 25 |
print(1.234) # same |
| 26 |
xfun::decimal_dot(as.character(1.234)) # using dot |
| 27 |
xfun::decimal_dot(print(1.234)) # using dot |
| 28 |
options(opts) |
| 29 |
} |