向森林图添加线

时间:2019-04-03 16:01:54

标签: r forestplot

我想在表格中添加一行,将列标签(粗体显示)与下面的数据分开。我有使用hrzl_lines函数的bean,但是我找不到一种方法来使行出现在林图的任何部分。

我还想在森林图中各行的结尾处添加晶须。我已经包含了vertices = TRUE,但这是行不通的。

forestplot_acm <-
  structure(list(
    coeff = c(NA, NA, 1.19, 1.09, 1.11, 1.12, NA),
    lower = c(NA, NA, 1.09, 1.01, 1.01, 1.02,NA),
    upper = c(NA, NA, 1.30, 1.22, 1.22, 1.23, NA)),
    .Names = c("coeff","lower","upper"),
    row.names =c(NA,-7L),
    class = "data.frame")

tabletext <- cbind(
c("", "Model Name", "Base Model", "Model 1", "Model 2", "Model 3", NA),
c("", "HR", "1.19", "1.09", "1.11", "1.11", NA),
c("", "P Value", "<0.001", "0.03", "0.03","0.02", NA))

forestplot(tabletext,
           hrzl_lines = list("2" = gpar(lty = 2, col="#000044")),
           forestplot_acm$coeff, 
           forestplot_acm$lower,
           forestplot_acm$upper, 
           zero = 1,
           is.summary=c(TRUE,TRUE,rep(FALSE,5)),
           line.margin = (0.2),
           xticks = c(1,1.05,1.1,1.15,1.2,1.25,1.3,1.35),
           col=fpColors(box="royalblue",line="black", hrz_lines = 
           "#000044"),
           lineheight = "auto",
           vertices = TRUE)

0 个答案:

没有答案