Often a user just wants to draw a quick chart of study results using only summary data. For instance, you may be looking at a table of hazard ratios and their confidence intervals and would like to visualise the results instead of working with the table.
This short script can take a vector of estimates, along with 95% CIs and will draw a chart.
17.2 Libraries
library(tidyverse)
── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr 1.1.4 ✔ readr 2.1.5
✔ forcats 1.0.0 ✔ stringr 1.5.1
✔ ggplot2 3.5.1 ✔ tibble 3.2.1
✔ lubridate 1.9.3 ✔ tidyr 1.3.1
✔ purrr 1.0.2
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag() masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
17.3 Dummy Data
Start by building a data frame using tibble. You should provide some labels (here IMD), along with an estimate (ABSOLUTE.CHANGE) and both lower (LCI) and upper (UCL) confidence limits
There’s nothing clever about this chart. It uses geom_point to draw the estimates, then uses geom_errorbar to add the upper and lower confidence limits.
If you have some point estimates and know the sample size, but don’t have confidence intervals, then you can calculate the confidence intervals using [this method](../examples/95CI_point_estimate.qmd)