在metafor中增加森林地块数据的空白

时间:2017-01-04 17:11:55

标签: r forestplot metafor

我是R的新手,正在使用metafor软件包forest.default实施创建包含数据集的森林图(我只有x ,森林地图数据中的ci.ubci.ub

我差不多完成了,我的情节看起来与this类似,只是我的数据超过了图表顶部的黑色水平边框。我使用过它,但是我有一个森林图总是与水平边框在同一行上,并且用白线叠加也没有提到here

我的问题是:如何在数据集中添加间隙,以便森林图本身将黑色边框向上移动?This is the image of the plot currently with the border (currently superimposed with a white line) cutting through my data

谢谢!

编辑:这是代码的片段

 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 个答案:

答案 0 :(得分:1)

您需要调整ylim参数。执行以下操作:

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

(其中[...]是您的所有其余代码)。然后查看ylim的默认值。通过在上面的值中添加2来调整此值(因为您为子组标题添加了两行),然后在调用ylim=c(lower,upper)时使用forest()