cli_format

0th

Percentile

Format a value for printing

This function can be used directly, or via the {.val ...} inline style. {.val {expr}} calls cli_format() automatically on the value of expr, before styling and collapsing it.

Usage
cli_format(x, style = list(), ...)

# S3 method for default cli_format(x, style = list(), ...)

# S3 method for character cli_format(x, style = list(), ...)

# S3 method for numeric cli_format(x, style = list(), ...)

Arguments
x

The object to format.

style

List of formatting options, see the individual methods for the style options they support.

...

Additional arguments for methods.

Details

It is possible to define new S3 methods for cli_format and then these will be used automatically for {.cal ...} expressions.

Aliases
  • cli_format
  • cli_format.default
  • cli_format.character
  • cli_format.numeric
Examples
# NOT RUN {
things <- c(rep("this", 3), "that")
cli_format(things)
cli_text("{.val {things}}")

nums <- 1:5 / 7
cli_format(nums, style = list(digits = 2))
cli_text("{.val {nums}}")
divid <- cli_div(theme = list(.val = list(digits = 3)))
cli_text("{.val {nums}}")
cli_end(divid)
# }
Documentation reproduced from package cli, version 2.0.1, License: MIT + file LICENSE

Community examples

Looks like there are no examples yet.