mirror of
https://github.com/agdamsbo/FreesearchR.git
synced 2025-09-12 18:09:39 +02:00
22 lines
619 B
R
22 lines
619 B
R
#' Print a flexible baseline characteristics table
|
|
#'
|
|
#' @param data data set
|
|
#' @param fun.args list of arguments passed to
|
|
#' @param fun function to
|
|
#' @param vars character vector of variables to include
|
|
#'
|
|
#' @return object of standard class for fun
|
|
#' @export
|
|
#'
|
|
#' @examples
|
|
#' mtcars |> baseline_table()
|
|
#' mtcars |> baseline_table(fun.args = list(by = "gear"))
|
|
baseline_table <- function(data, fun.args = NULL, fun = gtsummary::tbl_summary, vars = NULL) {
|
|
if (!is.null(vars)) {
|
|
data <- data |> dplyr::select(dplyr::all_of(vars))
|
|
}
|
|
|
|
out <- do.call(fun, c(list(data = data), fun.args))
|
|
return(out)
|
|
}
|
|
|