Initial commit

This commit is contained in:
Andreas Gammelgaard Damsbo 2024-11-08 15:13:33 +01:00
commit ccab72aa0f
31 changed files with 6547 additions and 0 deletions

22
R/baseline_table.R Normal file
View file

@ -0,0 +1,22 @@
#' 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 <- dplyr::select(dplyr::all_of(vars))
}
out <- do.call(fun, c(list(data = data), fun.args))
return(out)
}