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
40
R/regression_table.R
Normal file
40
R/regression_table.R
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
#' Create table of regression model
|
||||
#'
|
||||
#' @param data regression model
|
||||
#' @param args.list list of arguments passed to 'fun'.
|
||||
#' @param fun function to use for table creation. Default is "gtsummary::tbl_regression".
|
||||
#'
|
||||
#' @return object of standard class for fun
|
||||
#' @export
|
||||
#'
|
||||
#' @examples
|
||||
#' gtsummary::trial |>
|
||||
#' regression_model(
|
||||
#' outcome.str = "stage",
|
||||
#' fun = "MASS::polr"
|
||||
#' ) |>
|
||||
#' regression_table(args.list = list(exponentiate = TRUE))
|
||||
#' gtsummary::trial |>
|
||||
#' regression_model(
|
||||
#' outcome.str = "age",
|
||||
#' fun = "stats::lm",
|
||||
#' formula.str = "{outcome.str}~.",
|
||||
#' args.list = NULL
|
||||
#' ) |>
|
||||
#' regression_table()
|
||||
#' gtsummary::trial |>
|
||||
#' regression_model(
|
||||
#' outcome.str = "trt",
|
||||
#' fun = "stats::glm",
|
||||
#' args.list = list(family = binomial(link = "logit"))
|
||||
#' ) |>
|
||||
#' regression_table()
|
||||
regression_table <- function(data, args.list = NULL, fun = "gtsummary::tbl_regression") {
|
||||
|
||||
if (any(c(length(class(data))!=1, class(data)!="lm"))){
|
||||
args.list <- c(args.list,list(exponentiate=TRUE))
|
||||
}
|
||||
|
||||
out <- do.call(getfun(fun), c(list(x = data), args.list))
|
||||
return(out)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue