plot_errorbar {forestly} | R Documentation |
Plot to display risk difference
Description
Create a plot to display risk difference for each item.
Usage
plot_errorbar(
tbl,
y_var,
errbar_width = 0.4,
color = NULL,
shape = NULL,
label,
x_breaks = NULL,
grp_abbrev = "paired",
favor_direction = "negative",
vline = NULL,
line_type = 1,
title = "Risk Diff. + 95% CI \n (Percentage Points)",
background_color = c("#69B8F7", "#FFFFFF"),
background_alpha = 0.3,
theme = theme_panel(show_text = TRUE, show_ticks = TRUE),
legend_nrow = 1
)
Arguments
tbl |
A data frame selected from input data set to display on this plot. y and x variables are required. |
y_var |
A character string that specifies a variable to be displayed on the y-axis. |
errbar_width |
A numeric value to define the error bar width.
Default is 0.4. Value of this argument will be a half length of the
error bar, for example, |
color |
Color for each treatment group. |
shape |
Shape for each treatment group. Default is circle and square. Input values could be either a character or numeric value, For details, see https://ggplot2.tidyverse.org/articles/ggplot2-specs.html. |
label |
A character vector of labels for each treatment group. The control group label should be specified as the last element of the vector. |
x_breaks |
A numeric vector for x-axis breaks. Default is |
grp_abbrev |
A character vector for displaying the treatment groups
on a favor bar.
If |
favor_direction |
The position of a favor label under the condition
"comparison is treatment – control". For AEs, |
vline |
Vertical reference line position. Default is |
line_type |
Reference line type. Default is solid line.
Users can define one or multiple line types in a vector
(can be numeric such as 1, 2, 3 or character such as |
title |
Plot title. Default is |
background_color |
Plot background color. Default is
|
background_alpha |
Opacity of the background. Default is 0.3.
The value of this argument is the input for |
theme |
Panel theme, including the y-axis text, ticks, and plot margin.
Default is |
legend_nrow |
Integer, the number of rows for a legend display.
Must be smaller than or equal to the number of the treatment groups.
To omit the legend, set this to |
Value
A risk difference plot for each item.
Examples
forestly_adsl$TRTA <- factor(
forestly_adsl$TRT01A,
levels = c("Xanomeline Low Dose", "Placebo"),
labels = c("Low Dose", "Placebo")
)
forestly_adae$TRTA <- factor(
forestly_adae$TRTA,
levels = c("Xanomeline Low Dose", "Placebo"),
labels = c("Low Dose", "Placebo")
)
meta <- meta_forestly(
dataset_adsl = forestly_adsl,
dataset_adae = forestly_adae,
population_term = "apat",
observation_term = "wk12",
parameter_term = "any;rel;ser"
) |>
prepare_ae_forestly() |>
format_ae_forestly()
meta_any <- meta$tbl[1:20, ] |> dplyr::filter(parameter == "any")
meta_any |>
dplyr::select(name, diff_1, lower_1, upper_1) |>
plot_errorbar(
y_var = "name",
label = c("Treatment", "Placebo")
)