Learn R Programming

lares (version 4.8.4)

formatNum: Nicely Format Numerical Values

Description

This function lets the user format numerical values nicely

Usage

formatNum(
  x,
  decimals = 2,
  type = getOption("lares.formatNum"),
  scientific = FALSE,
  pre = "",
  pos = "",
  abbr = FALSE
)

Arguments

x

Numerical Vector

decimals

Integer. Amount of decimals to display

type

Integer. 1 for International standards. 2 for American Standards. Use options("lares.formatNum" = 2) to set this parameter globally.

scientific

Boolean. Scientific notation?

pre, pos

Character. Add string before or after number

abbr

Boolean. Abbreviate using num_abbr()? You can use the `decimals` parameter to set abbr's `n`(-1) parameter.

See Also

Other Data Wrangling: balance_data(), categ_reducer(), cleanText(), date_cuts(), date_feats(), dateformat(), formatTime(), holidays(), impute(), left(), normalize(), numericalonly(), ohe_commas(), ohse(), rbind_full(), removenacols(), removenarows(), replaceall(), right(), textFeats(), textTokenizer(), vector2text(), year_month(), year_week()

Examples

Run this code
# NOT RUN {
formatNum(1.23456, decimals = 3)
formatNum(1.23456, type = 1)
formatNum(1.23456, pre = "$", pos = "/p")
formatNum(123456, abbr = TRUE)
formatNum(1234567890, abbr = TRUE)
formatNum(1234567890, decimals = 0, abbr = TRUE)
# }

Run the code above in your browser using DataLab