# 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")
Run the code above in your browser using DataLab