Create a forest plot from an rtable with x transform settings
Source: R/forest_plot_decorator.R
g_forest_with_transform.Rd
Given a
rtables::rtable() object with at least one column with a single value and one column with 2
values, converts table to a ggplot2::ggplot() object and generates an accompanying forest plot. The
table and forest plot are printed side-by-side.
Usage
g_forest_with_transform(
tbl,
col_x = attr(tbl, "col_x"),
col_ci = attr(tbl, "col_ci"),
vline = 1,
forest_header = attr(tbl, "forest_header"),
xlim = c(0.1, 10),
transform_x = NA,
x_at = c(0.1, 1, 10),
width_columns = NULL,
lbl_col_padding = 0,
rel_width_forest = 0.25,
font_size = 12,
col_symbol_size = attr(tbl, "col_symbol_size"),
col = getOption("ggplot2.discrete.colour")[1],
ggtheme = NULL,
as_list = FALSE
)Arguments
- tbl
(
VTableTree)rtablestable with at least one column with a single value and one column with 2 values.- col_x
(
integer(1)orNULL)
column index with estimator. By default tries to get this fromtblattributecol_x, otherwise needs to be manually specified. IfNULL, points will be excluded from forest plot.- col_ci
(
integer(1)orNULL)
column index with confidence intervals. By default tries to get this fromtblattributecol_ci, otherwise needs to be manually specified. IfNULL, lines will be excluded from forest plot.- vline
(
numeric)
position of the vertical reference line on the plot. like 0 and 1 in forest plot.- forest_header
(
character(2))
text displayed to the left and right ofvline, respectively. Ifvline = NULLthenforest_headeris not printed. By default tries to get this fromtblattributeforest_header. IfNULL, defaults will be extracted from the table if possible, and set to"Comparison\nBetter"and"Treatment\nBetter"if not.- xlim
(
numeric)
range of x-axis limits. Example:c(0.1, 10)- transform_x
(
character)
function for x-values transformation- x_at
(
numeric)
specifies the tick marks on the axis. The value ofunion(xlim, vline)or Example:c(0.1,1,10).- width_columns
(
numeric)
a vector of column widths. Each element's position incolwidthscorresponds to the column oftblin the same position. IfNULL, column widths are calculated according to maximum number of characters per column.- lbl_col_padding
(
numeric)
padding between label and columns value. Default is0.- rel_width_forest
(
proportion)
proportion of total width to allocate to the forest plot. Relative width of table is then1 - rel_width_forest. Ifas_list = TRUE, this parameter is ignored.- font_size
(
numeric(1))
font size.- col_symbol_size
(
numericorNULL)
column index fromtblcontaining data to be used to determine relative size for estimator plot symbol. Typically, the symbol size is proportional to the sample size used to calculate the estimator. IfNULL, the same symbol size is used for all subgroups. By default tries to get this fromtblattributecol_symbol_size, otherwise needs to be manually specified.- col
(
character)
color(s).- ggtheme
(
theme)
a graphical theme as provided byggplot2to control styling of the plot.- as_list
(
flag)
whether the twoggplotobjects should be returned as a list. IfTRUE, a named list with two elements,tableandplot, will be returned. IfFALSE(default) the table and forest plot are printed side-by-side viacowplot::plot_grid().