apply_formats: Apply Format Strings outside of a Tplyr table

View source: R/apply_formats.R

apply_formatsR Documentation

Apply Format Strings outside of a Tplyr table

Description

The f_str object in Tplyr is used to drive formatting of the outputs strings within a Tplyr table. This function allows a user to use the same interface to apply formatted string on any data frame within a dplyr::mutate() context.

Usage

apply_formats(format_string, ..., empty = c(.overall = ""))

Arguments

format_string

The desired display format. X's indicate digits. On the left, the number of x's indicates the integer length. On the right, the number of x's controls decimal precision and rounding. Variables are inferred by any separation of the 'x' values other than a decimal.

...

The variables to be formatted using the format specified in format_string. These must be numeric variables.

empty

The string to display when the numeric data is not available. Use a single element character vector, with the element named '.overall' to instead replace the whole string.

Details

Note that auto-precision is not currently supported within apply_formats()

Value

Character vector of formatted values

Examples


library(dplyr)

mtcars %>%
  head() %>%
  mutate(
    fmt_example = apply_formats('xxx (xx.x)', hp, wt)
  )

Tplyr documentation built on May 29, 2024, 10:37 a.m.