default_stats_formats_labels | R Documentation |
Utility functions to get valid statistic methods for different method groups
(.stats
) and their associated formats (.formats
), labels (.labels
), and indent modifiers
(.indent_mods
). This utility is used across tern
, but some of its working principles can be
seen in analyze_vars()
. See notes to understand why this is experimental.
get_stats(
method_groups = "analyze_vars_numeric",
stats_in = NULL,
add_pval = FALSE
)
get_formats_from_stats(stats, formats_in = NULL)
get_labels_from_stats(stats, labels_in = NULL, row_nms = NULL)
get_indents_from_stats(stats, indents_in = NULL, row_nms = NULL)
tern_default_stats
tern_default_formats
tern_default_labels
summary_formats(type = "numeric", include_pval = FALSE)
summary_labels(type = "numeric", include_pval = FALSE)
method_groups |
( |
stats_in |
( |
add_pval |
( |
stats |
( |
formats_in |
(named |
labels_in |
(named |
row_nms |
( |
indents_in |
(named |
type |
( |
include_pval |
( |
tern_default_stats
is a named list of available statistics, with each element
named for their corresponding statistical method group.
tern_default_formats
is a named vector of available default formats, with each element
named for their corresponding statistic.
tern_default_labels
is a named character
vector of available default labels, with each element
named for their corresponding statistic.
Current choices for type
are counts
and numeric
for analyze_vars()
and affect get_stats()
.
get_stats()
returns a character
vector of statistical methods.
get_formats_from_stats()
returns a named vector of formats (if present in either
tern_default_formats
or formats_in
, otherwise NULL
). Values can be taken from
formatters::list_valid_format_labels()
or a custom function (e.g. formatting_functions).
get_labels_from_stats()
returns a named character
vector of labels (if present in either
tern_default_labels
or labels_in
, otherwise NULL
).
get_indents_from_stats()
returns a single indent modifier value to apply to all rows
or a named numeric vector of indent modifiers (if present, otherwise NULL
).
summary_formats()
returns a named vector
of default statistic formats for the given data type.
summary_labels
returns a named vector
of default statistic labels for the given data type.
get_stats()
: Get statistics available for a given method
group (analyze function). To check available defaults see tern::tern_default_stats
list.
get_formats_from_stats()
: Get formats corresponding to a list of statistics.
To check available defaults see tern::tern_default_formats
list.
get_labels_from_stats()
: Get labels corresponding to a list of statistics.
To check for available defaults see tern::tern_default_labels
list. If not available there,
the statistics name will be used as label.
get_indents_from_stats()
: Format indent modifiers for a given vector/list of statistics.
It defaults to 0L for all values.
tern_default_stats
: Named list of available statistics by method group for tern
.
tern_default_formats
: Named vector of default formats for tern
.
tern_default_labels
: Named character
vector of default labels for tern
.
summary_formats()
:
Quick function to retrieve default formats for summary statistics:
analyze_vars()
and analyze_vars_in_cols()
principally.
summary_labels()
:
Quick function to retrieve default labels for summary statistics.
Returns labels of descriptive statistics which are understood by rtables
. Similar to summary_formats
.
These defaults are experimental because we use the names of functions to retrieve the default statistics. This should be generalized in groups of methods according to more reasonable groupings.
Formats in tern
and rtables
can be functions that take in the table cell value and
return a string. This is well documented in vignette("custom_appearance", package = "rtables")
.
formatting_functions
# analyze_vars is numeric
num_stats <- get_stats("analyze_vars_numeric") # also the default
# Other type
cnt_stats <- get_stats("analyze_vars_counts")
# Weirdly taking the pval from count_occurrences
only_pval <- get_stats("count_occurrences", add_pval = TRUE, stats_in = "pval")
# All count_occurrences
all_cnt_occ <- get_stats("count_occurrences")
# Multiple
get_stats(c("count_occurrences", "analyze_vars_counts"))
# Defaults formats
get_formats_from_stats(num_stats)
get_formats_from_stats(cnt_stats)
get_formats_from_stats(only_pval)
get_formats_from_stats(all_cnt_occ)
# Addition of customs
get_formats_from_stats(all_cnt_occ, formats_in = c("fraction" = c("xx")))
get_formats_from_stats(all_cnt_occ, formats_in = list("fraction" = c("xx.xx", "xx")))
# Defaults labels
get_labels_from_stats(num_stats)
get_labels_from_stats(cnt_stats)
get_labels_from_stats(only_pval)
get_labels_from_stats(all_cnt_occ)
# Addition of customs
get_labels_from_stats(all_cnt_occ, labels_in = c("fraction" = "Fraction"))
get_labels_from_stats(all_cnt_occ, labels_in = list("fraction" = c("Some more fractions")))
get_indents_from_stats(all_cnt_occ, indents_in = 3L)
get_indents_from_stats(all_cnt_occ, indents_in = list(count = 2L, count_fraction = 5L))
get_indents_from_stats(
all_cnt_occ,
indents_in = list(a = 2L, count.a = 1L, count.b = 5L), row_nms = c("a", "b")
)
summary_formats()
summary_formats(type = "counts", include_pval = TRUE)
summary_labels()
summary_labels(type = "counts", include_pval = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.