View source: R/apply_formats.R
apply_formats | R Documentation |
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.
apply_formats(format_string, ..., empty = c(.overall = ""))
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
|
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. |
Note that auto-precision is not currently supported within apply_formats()
Character vector of formatted values
library(dplyr)
mtcars %>%
head() %>%
mutate(
fmt_example = apply_formats('xxx (xx.x)', hp, wt)
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.