View source: R/formatting_functions.R
format_auto | R Documentation |
Formatting function for the majority of default methods used in analyze_vars()
.
For non-derived values, the significant digits of data is used (e.g. range), while derived
values have one more digits (measure of location and dispersion like mean, standard deviation).
This function can be called internally with "auto" like, for example,
.formats = c("mean" = "auto")
. See details to see how this works with the inner function.
format_auto(dt_var, x_stat)
dt_var |
( |
x_stat |
( |
The internal function is needed to work with rtables
default structure for
format functions, i.e. function(x, ...)
, where is x are results from statistical evaluation.
It can be more than one element (e.g. for .stats = "mean_sd"
).
A string that rtables
prints in a table cell.
Other formatting functions:
extreme_format
,
format_count_fraction()
,
format_count_fraction_fixed_dp()
,
format_count_fraction_lt10()
,
format_extreme_values()
,
format_extreme_values_ci()
,
format_fraction()
,
format_fraction_fixed_dp()
,
format_fraction_threshold()
,
format_sigfig()
,
format_xx()
,
formatting_functions
x_todo <- c(0.001, 0.2, 0.0011000, 3, 4)
res <- c(mean(x_todo[1:3]), sd(x_todo[1:3]))
# x is the result coming into the formatting function -> res!!
format_auto(dt_var = x_todo, x_stat = "mean_sd")(x = res)
format_auto(x_todo, "range")(x = range(x_todo))
no_sc_x <- c(0.0000001, 1)
format_auto(no_sc_x, "range")(x = no_sc_x)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.