tidy_as_ard {cards} | R Documentation |
Build ARD from Tidier
Description
Function converts a model's one-row tidy data frame into an ARD structure.
The tidied data frame must have been constructed with
eval_capture_conditions()
.
This function is primarily for developers and few consistency checks have been included.
Usage
tidy_as_ard(
lst_tidy,
tidy_result_names,
fun_args_to_record = character(0L),
formals = list(),
passed_args = list(),
lst_ard_columns
)
Arguments
lst_tidy |
(named |
tidy_result_names |
( |
fun_args_to_record |
( |
formals |
( |
passed_args |
(named |
lst_ard_columns |
(named |
Value
an ARD data frame of class 'card'
Examples
# example how one may create a fisher.test() ARD function
my_ard_fishertest <- function(data, by, variable, ...) {
# perform fisher test and format results -----------------------------------
lst_tidy_fisher <-
eval_capture_conditions(
# this manipulation is similar to `fisher.test(...) |> broom::tidy()`
stats::fisher.test(x = data[[variable]], y = data[[by]], ...)[c("p.value", "method")] |>
as.data.frame()
)
# build ARD ------------------------------------------------------------------
tidy_as_ard(
lst_tidy = lst_tidy_fisher,
tidy_result_names = c("p.value", "method"),
fun_args_to_record =
c(
"workspace", "hybrid", "hybridPars", "control", "or",
"conf.int", "conf.level", "simulate.p.value", "B"
),
formals = formals(stats::fisher.test),
passed_args = dots_list(...),
lst_ard_columns = list(group1 = by, variable = variable, context = "fishertest")
)
}
my_ard_fishertest(mtcars, by = "am", variable = "vs")