This function lets the user format numerical values nicely
formatNum(
x,
decimals = 2,
signif = NULL,
type = Sys.getenv("LARES_NUMFORMAT"),
pre = "",
pos = "",
sign = FALSE,
abbr = FALSE,
...
)
Numerical Vector
Integer. Amount of decimals to display. If set to
NULL
, then getOption("digits")
will be used.
Integer. Rounds the values in its first argument to the specified number of significant digits.
Integer. 1
for International standards. 2
for American Standards. Use Sys.setenv("LARES_NUMFORMAT" = 2)
to set this parameter globally.
Character. Add string before or after number.
Boolean. Add +
sign to positive values.
Boolean. Abbreviate using num_abbr()? You can use
the `decimals` parameter to set abbr's n
(-1) parameter.
Additional lazy eval parameters.
Character. String vector with reformatted continuous numbers
Other Data Wrangling:
balance_data()
,
categ_reducer()
,
cleanText()
,
date_cuts()
,
date_feats()
,
holidays()
,
impute()
,
left()
,
normalize()
,
numericalonly()
,
ohe_commas()
,
ohse()
,
removenacols()
,
removenarows()
,
replaceall()
,
textFeats()
,
textTokenizer()
,
vector2text()
,
year_month()
,
year_week()
# NOT RUN {
formatNum(1.23456, decimals = 3)
formatNum(1.23456, type = 1)
formatNum(1.23456, pre = "$", pos = "/person")
formatNum(123456, abbr = TRUE)
formatNum(1234567890, abbr = TRUE, signif = 2)
formatNum(1234567890, decimals = 0, abbr = TRUE)
formatNum(c(-3:3), sign = TRUE)
# }
Run the code above in your browser using DataLab