1 ```#' Produce a table and plot ``` 2 ```#' ``` 3 ```#' Wraps \code{\link{or_plot}}, \code{\link{hr_plot}}, and ``` 4 ```#' \code{\link{coefficient_plot}} and sends to the appropriate method depending ``` 5 ```#' on the dependent variable type. ``` 6 ```#' @param .data Data frame. ``` 7 ```#' @param dependent Character vector of length 1. ``` 8 ```#' @param explanatory Character vector of any length: name(s) of explanatory ``` 9 ```#' variables. ``` 10 ```#' @param ... Pass arguments \code{\link{or_plot}}, \code{\link{hr_plot}}, or ``` 11 ```#' \code{\link{coefficient_plot}} ``` 12 ```#' ``` 13 ```#' @return A table and a plot using \code{\link{ggplot2}} ``` 14 ```#' @export ``` 15 ```#' @family finalfit plot functions ``` 16 ```#' @examples ``` 17 ```#' # Coefficient plot ``` 18 ```#' explanatory = c("age.factor", "sex.factor", "obstruct.factor", "perfor.factor") ``` 19 ```#' dependent = "nodes" ``` 20 ```#' colon_s %>% ``` 21 ```#' ff_plot(dependent, explanatory) ``` 22 ```#' ``` 23 ```#' # Odds ratio plot ``` 24 ```#' dependent = "mort_5yr" ``` 25 ```#' colon_s %>% ``` 26 ```#' ff_plot(dependent, explanatory) ``` 27 ```#' ``` 28 ```#' # Hazard ratio plot ``` 29 ```#' dependent = "Surv(time, status)" ``` 30 ```#' colon_s %>% ``` 31 ```#' ff_plot(dependent, explanatory, dependent_label = "Survival") ``` 32 ```ff_plot <- function(.data, dependent, explanatory, ...){ ``` 33 1 ``` if(is.data.frame(.data)==FALSE) stop(".data is not dataframe") ``` 34 1 ``` if(is.null(explanatory)) stop("No explanatory variable(s) provided") ``` 35 1 ``` if(is.null(dependent)) stop("No dependent variable provided") ``` 36 ``` ``` 37 ``` # Args ``` 38 1 ``` args = list(.data, dependent, explanatory, ...) ``` 39 ``` ``` 40 ``` # What is dependent variable ``` 41 1 ``` d_variable = .data[,names(.data) %in% dependent] ``` 42 1 ``` if(is.survival(dependent)){ ``` 43 1 ``` d_type = "survival" ``` 44 ``` }else{ ``` 45 1 ``` d_type = variable_type(d_variable) ``` 46 ``` } ``` 47 ``` # Send to method ``` 48 1 ``` if (d_type == "survival"){ ``` 49 1 ``` do.call(hr_plot, args) ``` 50 1 ``` } else if (d_type == "factor" || d_type == "character" || d_type == "logical"){ ``` 51 1 ``` do.call(or_plot, args) ``` 52 1 ``` } else if (d_type == "numeric"){ ``` 53 1 ``` do.call(coefficient_plot, args) ``` 54 ``` } else { ``` 55 0 ``` stop("Plotting not support for this dependent variable type") ``` 56 ``` } ``` 57 ```} ``` 58 59 ```#' @rdname ff_plot ``` 60 ```#' @export ``` 61 ```finalfit_plot = ff_plot ```

Read our documentation on viewing source code .