Skip to content

Commit

Permalink
Close #1026: Expose gpar to control graphic settings in g_forest. (#1057
Browse files Browse the repository at this point in the history
)

Closes #1026
  • Loading branch information
anajens authored Sep 12, 2023
1 parent 5deea96 commit a39ed62
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down
5 changes: 4 additions & 1 deletion R/g_forest.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
#'
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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))
)

Expand Down
2 changes: 2 additions & 0 deletions inst/WORDLIST
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,14 @@ biomarkers
coercible
funder
layouting
params
poisson
pre
quasipoisson
repo
responder
responders
rtables
subtable
subtables
unformatted
Expand Down
7 changes: 6 additions & 1 deletion man/g_forest.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a39ed62

Please sign in to comment.