Description Usage Arguments Value Note Author(s) Examples
Visualize multiple measures of effect with their confidence intervals in a vertical layout.
1 2 3 4 5 6 7 8 9 10 11 12 13 |
df |
A data frame with the data to plot. It must contain at least three
variables, a character column with the names to be displayed on the y-axis
(see parameter |
name |
the variable in |
estimate |
the variable in |
se |
the variable in the |
pvalue |
the variable in |
colour |
the variable in |
shape |
the variable in |
logodds |
logical (defaults to FALSE) specifying whether the |
psignif |
numeric, defaults to 0.05. The p-value threshold
for statistical significance. Entries with larger than |
ci |
A number between 0 and 1 (defaults to 0.95) indicating the type of confidence interval to be drawn. |
... |
|
A ggplot
object.
See vignette(programming, package = "dplyr")
for an
introduction to non-standard evaluation.
Maria Kalimeri, Ilari Scheinin, Vilma Jagerroos
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | library(magrittr)
# Linear associations
# Get subset of example data frame
df_linear <-
df_linear_associations %>%
dplyr::arrange(name) %>%
dplyr::filter(dplyr::row_number() <= 30)
# Forestplot
forestplot(
df = df_linear,
estimate = beta,
logodds = FALSE,
colour = trait,
xlab = "1-SD increment in cardiometabolic trait
per 1-SD increment in biomarker concentration"
)
# Log odds ratios
df_logodds <-
df_logodds_associations %>%
dplyr::arrange(name) %>%
dplyr::filter(dplyr::row_number() <= 30) %>%
# Set the study variable to a factor to preserve order of appearance
# Set class to factor to set order of display.
dplyr::mutate(
study = factor(
study,
levels = c("Meta-analysis", "NFBC-1997", "DILGOM", "FINRISK-1997", "YFS")
)
)
# Forestplot
forestplot(
df = df_logodds,
estimate = beta,
logodds = TRUE,
colour = study,
xlab = "Odds ratio for incident type 2 diabetes (95% CI)
per 1-SD increment in biomarker concentration"
)
# For the latter, if you want to restrain the x-axis and crop the large
# errorbar for Acetate you may add the following coord_cartesian layer
forestplot(
df = df_logodds,
estimate = beta,
logodds = TRUE,
colour = study,
shape = study,
xlab = "Odds ratio for incident type 2 diabetes (95% CI)
per 1-SD increment in biomarker concentration",
xlim = c(0.5, 2.2),
# You can explicitly define x-tick breaks
xtickbreaks = c(0.5, 0.8, 1.0, 1.2, 1.5, 2.0)
) +
# You may also want to add a manual shape to mark meta-analysis with a
# diamond shape
ggplot2::scale_shape_manual(
values = c(23L, 21L, 21L, 21L, 21L),
labels = c("Meta-analysis", "NFBC-1997", "DILGOM", "FINRISK-1997", "YFS")
)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.