Help modifying forest plots

Hi R Community,

I am hitting a stumper - and it is probably an easy fix.

I have a forest plot that I built below and I am trying to make a few changes to it:

  1. Order the studies to correspond to the TALC, where the first column is the TALC column (left one)? In other words order TALC, LRR, Hedges g.

  2. Fit the published and unpublished Effect Sizes in there too with space between studies?

  3. Add light grey shading to cover the confidence intervals using the "Omnibus Effect Sizes" values in the csv (i.e., Overall Median/Mean section) and then use that same shading down each column for the published and unpublished sections for all columns and remove the omnibus values at the top.

*For 2 and 3 the very bottom plot shows what the intent is.

Here is my code in markdown to create the black and white forest plot:


forest %>%
  mutate(effect_size = factor(effect_size, 
                              levels = c("lrr", "hedges", "talc"),
                              labels = c("LRR (% Changed)", "Hedges' g", "TALC"))) |> 
  arrange(effect_size, ES_mean) %>% 
  mutate(citation = fct_inorder(citation),
         status = factor(status, levels = c("o", "p", "u"), 
                         labels = c("", "Published", "Unpublished"))) %>% 
  ggplot(aes(y = citation, 
               x = ES_mean, 
               xmin = CI_lower_mean, 
               xmax = CI_upper_mean, 
               color = citation)) +
      geom_pointrange() + 
      geom_vline(xintercept = 0) + 
      facet_grid(rows = vars(status), 
                 cols = vars(effect_size), 
                 scales = "free", 
                 space = "free_y") +
      theme_light() + 
      theme(legend.position = "none") + 
      labs(y = NULL, x = "Effect Size Comparison") +
      theme(text = element_text(size = 12, family = "TT Times New Roman")) 

pdf("Forest_Color.pdf")
print(forest)
dev.off()

Current plot:

Can't seem to post due to being a new user - sorry about that.

Aiming for something like the attachment with the changes (without the top prediction interval and overall mean metrics) just the shading:

Thank you for your help and guidance!

Hello.
Thanks for providing code , but you could take further steps to make it more convenient for other forum users to help you.

Share some representative data that will enable your code to run and show the problematic behaviour.

You might use tools such as the library datapasta, or the base function dput() to share a portion of data in code form, i.e. that can be copied from forum and pasted to R session.

Reprex Guide

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.