如何在 R 包 forestplot 中添加第二条垂直线
How to add a second vertical line in R package forestplot
我想在我的森林图中区分统计显着性 (OR = 1.0) 和临床显着性 (OR = 1.5)。我使用 forestplot 包创建了这个图,示例代码如下。是否可以添加垂直线(同时保持无差异线)?
library(forestplot)
test_data <- structure(list(
mean = c(NA, NA, 1, 0.5, 2),
lower = c(NA, NA, .5, .25, 1.5),
upper = c(NA, NA, 1.5, .75, 2.5)),
.Names = c("mean", "lower", "upper"),
row.names = c(NA, -5L),
class = "data.frame")
tabletext <- cbind(
c("", "Outcome", "Outcome 1", "Outcome 2", "Outcome 3"),
c("", "OR", "1 (0.5 - 1.5)", "0.5 (0.25 - 0.75)", "2.0 (1.5 - 2.5)"))
forestplot(tabletext,
test_data,
new_page = TRUE,
xlog = TRUE,
boxsize = .25
)
次优(而且不是很优雅)的解决方案可能是:1- 创建一个没有轴或标签的空图,2- 然后绘制一条垂直线 (abline(v=1.5)
) 和 3- 调用您的 forestplot
与 new_page = F
.
这是您要找的吗?
forestplot(tabletext,
test_data,
new_page = TRUE,
xlog = TRUE,
grid = structure(c(log(1.5)),
gp = gpar(lty = 2, col = "#CCCCFF")),
zero = 1,
boxsize = .25)
我想在我的森林图中区分统计显着性 (OR = 1.0) 和临床显着性 (OR = 1.5)。我使用 forestplot 包创建了这个图,示例代码如下。是否可以添加垂直线(同时保持无差异线)?
library(forestplot)
test_data <- structure(list(
mean = c(NA, NA, 1, 0.5, 2),
lower = c(NA, NA, .5, .25, 1.5),
upper = c(NA, NA, 1.5, .75, 2.5)),
.Names = c("mean", "lower", "upper"),
row.names = c(NA, -5L),
class = "data.frame")
tabletext <- cbind(
c("", "Outcome", "Outcome 1", "Outcome 2", "Outcome 3"),
c("", "OR", "1 (0.5 - 1.5)", "0.5 (0.25 - 0.75)", "2.0 (1.5 - 2.5)"))
forestplot(tabletext,
test_data,
new_page = TRUE,
xlog = TRUE,
boxsize = .25
)
次优(而且不是很优雅)的解决方案可能是:1- 创建一个没有轴或标签的空图,2- 然后绘制一条垂直线 (abline(v=1.5)
) 和 3- 调用您的 forestplot
与 new_page = F
.
这是您要找的吗?
forestplot(tabletext,
test_data,
new_page = TRUE,
xlog = TRUE,
grid = structure(c(log(1.5)),
gp = gpar(lty = 2, col = "#CCCCFF")),
zero = 1,
boxsize = .25)