Adding gaps in data for forest plot in metafor

1.5k views Asked by At

I'm new to R and working on creating a forest plot with a data set using the metafor package's forest.default implementation ( I only have the x, ci.ub and ci.ub in the data for the forest plot)

I'm almost done and my plot looks similar to this, except that my data goes over the black horizontal border on top of the graph. I worked with that, but I have one forest plot always on the same row as that of the horizontal border, and superimposing with a white line also doesn't help as mentioned here.

My question is this: How do I add gaps to my data set so that the forest plot itself shifts the black border up?This is the image of the plot currently with the border (currently superimposed with a white line) cutting through my data

Thanks!

EDIT: Here's a snippet of the code

 require(metafor)
  metafor::forest(
    x = as.vector(t(data_set[, forest_plot$mean])),
    xlim = c(min_x_value - 2 * (plot_span), max_x_value), 
    alim = c(min_x_value , max_x_value),
    ci.lb = as.vector(t(data_set[, forest_plot$low])),
    ci.ub = as.vector(t(data_set[, forest_plot$high])),
    col = "darkgoldenrod4",
    ilab = display_data_matrix,
    ilab.pos = 4,
    annotate = FALSE,
    slab = NA,
    ilab.xpos = c(min_x_value - 2 * plot_span, min_x_value - 1.5 * plot_span, min_x_value - 0.75 * plot_span, min_x_value - 0.25 * plot_span),
    rows = row_groupings,
    xlab = paste(measure, ep_type, ep)
  )
  # print("e")
  text(min_x_value - 2* plot_span, subgroup_rows, col = "brown3", pos = 4 , subgroup_titles, cex = 1.2)
  header_line <- dim(data_set)[1] + gaps + 1
  text( c(min_x_value - 2 * plot_span, 
          min_x_value - 1.5 * plot_span,
          min_x_value - 0.75 * plot_span,
          min_x_value - 0.25 * plot_span),
        pos = 4,
        cex = 1.4,
        col = "darkorchid4",
        header_line, c("Trial", "Randomized Treatment", "N Arm", "Time") )

  abline(h=dim(data_set)[1]+1, lwd=2, col="white")
1

There are 1 answers

1
Wolfgang On BEST ANSWER

You need to adjust the ylim argument. Do the following:

sav <- forest(x = [...])
sav

(where [...] is all the rest of your code). Then see what the default values for ylim are. Adjust this by adding 2 to the upper value (since you added two rows for the subgroup headings) and then use ylim=c(lower,upper) in your call to forest().