This function is intended to create forest plots based upon a data.frame
typically created by the make_gmr_data
function. The output is a
ggplot2 object.
make_forestplot(
data,
x,
xmin,
xmax,
y,
color,
reference,
label,
facet,
vline_primary = 1,
vline_secondary = c(0.8, 1.25),
xlb,
ylb,
title,
n_label = "individual",
fatten = 4,
small_font = FALSE,
is_facet_expression = NULL
)
a data.frame; typically created using make_gmr_data
the mapping variables represented by
geom_pointrange
the mapping variable providing the coloring information
the mapping variable defining whether levels of the
y
variable are reference ones.
the mapping variable providing the information displaying on the secondary Y axis
a single facetting variable (can be a vector of expression)
the X-axis values for which a primary and secondary vertical lines are drawn
optional axis and plot titles (can be expressions)
a character value defining how individuals are defined in the abbreviation in the table footnote, that is, what is used in the definition of 'n' (eg, 'n, number of individuals'). By default, a 's' will be added to the entered value.
a scaling factor of the points defined by x
a logical value indicating whether a smaller font size should be used
a logical value indicating whether the levels of
the facet
variable are expression (TRUE) or character (FALSE) objects;
if set to NULL, make_gmr_data
tries to make an educated guess
a ggplot2 plot object. See vignette('forest', package = 'ggcognigen')
more details of the different design variants that can be created.
if (FALSE) { # \dontrun{
# Use expo dataset provided in the ggcognigen package
gmrs <- expo %>%
make_gmr_data(
x_var = c(CMAXSS, AUCSS, CMINSS),
id_var = ID,
by = DOSE,
covariates = c(AGE, WTKG, BMI, SEXF, RFCAT, CPCAT),
labels = c(
expression('Age'~'(y)'),
expression('Body'~'Weight'~'(kg)'),
expression('Body'~'Mass'~'Index'~'(kg/'*m^2*')'),
expression('Sex'),
expression('Renal'~'Function'),
expression('Hepatic'~'Function')
),
ref_levels = c(2, 3, 2, 1, 1, 1),
digits = 3,
silent = TRUE
)
make_forestplot(
data = gmrs %>% dplyr::filter(x_var == "AUCSS"),
x = gmr,
xmin = gmr_lo,
xmax = gmr_hi,
y = value,
color = by,
label = gmr_n_label,
facet = y_label,
vline_primary = 1,
vline_secondary = c(0.8, 1.25),
xlb = 'Geometric Mean Ratio [90% confidence interval]',
title = expression(C[trough]~'(nmol/L)'),
fatten = 2,
small_font = TRUE
) +
scale_discrete_cognigen(n = 4, geom = 'point')
} # }