diff --git a/NEWS.md b/NEWS.md index 326ce0a5e2..47ad5c5d54 100644 --- a/NEWS.md +++ b/NEWS.md @@ -11,6 +11,7 @@ * Refactored `tabulate_rsp_subgroups` to pass sanitation checks by preventing creation of degenerate subtables. * Updated `analyze_vars_in_cols` to use caching, allow implementation of imputation rule via the `imp_rule` argument, and allow user to specify cell alignment via the `.aligns` argument. * Updated `add_rowcounts` to allow addition of row counts from `alt_counts_df` using the `alt_counts` argument. +* Added `gp` argument to `g_forest` to control graphical parameters such as font size. ### Miscellaneous * Grouped functions relating to valid method names and their default formats and labels into new source file `utils_defaults_handling.R`. diff --git a/R/g_forest.R b/R/g_forest.R index d06202e476..1c965a4fad 100644 --- a/R/g_forest.R +++ b/R/g_forest.R @@ -5,6 +5,7 @@ #' #' @description `r lifecycle::badge("stable")` #' +#' @inheritParams grid::gTree #' @inheritParams argument_convention #' @param tbl (`rtable`) #' @param col_x (`integer`)\cr column index with estimator. By default tries to get this from @@ -60,7 +61,7 @@ #' #' tbl <- basic_table() %>% #' tabulate_rsp_subgroups(df) -#' p <- g_forest(tbl) +#' p <- g_forest(tbl, gp = grid::gpar(fontsize = 10)) #' #' draw_grob(p) #' @@ -158,6 +159,7 @@ g_forest <- function(tbl, width_forest = grid::unit(1, "null"), col_symbol_size = attr(tbl, "col_symbol_size"), col = getOption("ggplot2.discrete.colour")[1], + gp = NULL, draw = TRUE, newpage = TRUE) { checkmate::assert_class(tbl, "VTableTree") @@ -241,6 +243,7 @@ g_forest <- function(tbl, width_forest, symbol_size = symbol_size, col = col, + gp = gp, vp = grid::plotViewport(margins = rep(1, 4)) ) diff --git a/inst/WORDLIST b/inst/WORDLIST index 06c569fd9d..41765f4080 100644 --- a/inst/WORDLIST +++ b/inst/WORDLIST @@ -22,12 +22,14 @@ biomarkers coercible funder layouting +params poisson pre quasipoisson repo responder responders +rtables subtable subtables unformatted diff --git a/man/g_forest.Rd b/man/g_forest.Rd index 694670ab8b..36d161cd12 100644 --- a/man/g_forest.Rd +++ b/man/g_forest.Rd @@ -18,6 +18,7 @@ g_forest( width_forest = grid::unit(1, "null"), col_symbol_size = attr(tbl, "col_symbol_size"), col = getOption("ggplot2.discrete.colour")[1], + gp = NULL, draw = TRUE, newpage = TRUE ) @@ -59,6 +60,10 @@ By default tries to get this from \code{tbl} attribute \code{col_symbol_size}, o \item{col}{(\code{character})\cr color(s).} +\item{gp}{A \code{"gpar"} object, typically the output + from a call to the function \code{\link[grid]{gpar}}. This is basically + a list of graphical parameter settings.} + \item{draw}{(\code{flag})\cr whether the plot should be drawn.} \item{newpage}{(\code{flag})\cr whether the plot should be drawn on a new page. @@ -102,7 +107,7 @@ df <- extract_rsp_subgroups( tbl <- basic_table() \%>\% tabulate_rsp_subgroups(df) -p <- g_forest(tbl) +p <- g_forest(tbl, gp = grid::gpar(fontsize = 10)) draw_grob(p)