mirror of
https://github.com/agdamsbo/FreesearchR.git
synced 2026-06-19 04:27:30 +02:00
Initial commit
This commit is contained in:
commit
ccab72aa0f
31 changed files with 6547 additions and 0 deletions
22
R/baseline_table.R
Normal file
22
R/baseline_table.R
Normal 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)
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue