phrase_nr: Phrase numeric vector

phrase_nrR Documentation

Phrase numeric vector

Description

Phrases a numeric vector by rounding, separating thousands and optionally other procedures. Basically a convenience wrapper around round_to() and base::format().

Usage

phrase_nr(
  x,
  round_to = 0.1,
  round_up = TRUE,
  big_mark = "'",
  decimal_mark = ".",
  justify_right = FALSE,
  ...
)

Arguments

x

A numeric vector to phrase.

round_to

Number to round x to. A numeric scalar.

round_up

Whether to round a remainder of exactly to / 2 up or not. Set to FALSE in order to round off.

big_mark

Character used between every 3 digits to separate thousands.

decimal_mark

Character used to indicate the numeric decimal point. Only relevant if x does not solely consist of integers.

justify_right

Whether to right-justify the results to a common width. See the trim parameter of base::format() for details.

...

Further arguments passed on to base::format().

Value

A character vector of the same length as x.

See Also

Other string functions: as_chr(), as_comment_str(), as_env_var_name(), as_line_feed_chr(), as_str(), capitalize_first(), dsv_colnames(), enum_str(), escape_lf(), fuse_regex(), sentenceify(), wrap_chr()

Examples

c(0.11, 11111.11) |> pal::phrase_nr()

c(0.11, 11111.11) |>
  pal::phrase_nr(justify_right = TRUE) |>
  pal::cat_lines()

salim-b/pal documentation built on June 9, 2025, 12:39 a.m.