森林图与边桌不符
Forest plot doesn't match the sidetable
我必须做一个森林图和边表,但我必须使用效应大小而不是使用优势比(像往常一样)。我根据在 Internet 上找到的另一个代码编写了这段代码,因为我需要 forestplot 和 sidetable。我编辑了我的问题以包含示例数据和我的部分解决方案。
library(forestplot)
####With this I create the data for the tabletext###
TE<-as.character(c(-0.05, 0.27, 0.39, 0.21, 0, 0.08, 0.28, 0.23, -0.16, 0.11, 0.13,
0.03, 0.78, 0.43, 0.07, 0.34, 0.58))
Inferior<-as.character(c(-0.55, -0.22, -0.11, -0.3, -0.31, -0.22, -0.03, -0.07, -0.47,
-0.19, -0.18, -0.27, 0.46, 0.12, -0.55, -0.07, 0.15))
Superior<-as.character(c(0.44, 0.76, 0.88, 0.73, 0.31, 0.39, 0.6, 0.54, 0.15, 0.42,
0.45, 0.34, 1.11, 0.74, 0.69, 0.75, 1.02))
Autor<-c("Cain & Smith", "Cain & Smith", "Cain & Smith", "Cain & Smith",
"Hoffman & Dangl", "Hoffman & Dangl", "Hoffman & Dangl", "Hoffman & Dangl",
"Hoffman & Dangl", "Hoffman & Dangl", "Hoffman & Dangl", "Hoffman & Dangl",
"Hoffman & Dangl", "Hoffman & Dangl", "Bunch", "Bunch", "Bunch")
###With this I create the values for the forest plot###
TE2<-c(NA, -0.05, 0.27, 0.39, 0.21, 0, 0.08, 0.28, 0.23, -0.16, 0.11, 0.13,
0.03, 0.78, 0.43, 0.07, 0.34, 0.58, NA, NA)
Inferior2<-c(NA, -0.55, -0.22, -0.11, -0.3, -0.31, -0.22, -0.03, -0.07, -0.47,
-0.19, -0.18, -0.27, 0.46, 0.12, -0.55, -0.07, 0.15, NA, NA)
Superior2<-c(NA, 0.44, 0.76, 0.88, 0.73, 0.31, 0.39, 0.6, 0.54, 0.15, 0.42, 0.45,
0.34, 1.11, 0.74, 0.69, 0.75, 1.02, NA, NA)
###With this I create the sidetable###
tabletext<-cbind(
c("Autor", Autor, NA, "Summary"),
c("Effect Size", TE, NA, NA),
c("Inferior", Inferior, NA, NA),
c("Superior", Superior, NA, "0.17"))
###With this I create the forestplot###
forestplot(tabletext,
hrzl_lines = gpar(col="#444444"),
mean = TE2, lower = Inferior2, upper = Superior2,
new_page = TRUE,
xlog=FALSE,
is.summary=c(TRUE, rep(FALSE,18), TRUE),
graph.pos=5,
boxsize=0.2,
col=fpColors(box="black",line="black", summary="black"))
我以前的问题是生成的森林图将效果大小向上移动了一行(因此,它们与边桌上的信息不匹配,因为从列标题级别开始)。现在,我唯一的问题是它没有将摘要添加到情节中。
非常感谢您的帮助!
您的问题是您没有将摘要信息添加到均值、上限和下限置信区间:
library(forestplot)
####With this I create the data for the tabletext###
TE<-as.character(c(-0.05, 0.27, 0.39, 0.21, 0, 0.08, 0.28, 0.23, -0.16, 0.11, 0.13,
0.03, 0.78, 0.43, 0.07, 0.34, 0.58))
Inferior<-as.character(c(-0.55, -0.22, -0.11, -0.3, -0.31, -0.22, -0.03, -0.07, -0.47,
-0.19, -0.18, -0.27, 0.46, 0.12, -0.55, -0.07, 0.15))
Superior<-as.character(c(0.44, 0.76, 0.88, 0.73, 0.31, 0.39, 0.6, 0.54, 0.15, 0.42,
0.45, 0.34, 1.11, 0.74, 0.69, 0.75, 1.02))
Autor<-c("Cain & Smith", "Cain & Smith", "Cain & Smith", "Cain & Smith",
"Hoffman & Dangl", "Hoffman & Dangl", "Hoffman & Dangl", "Hoffman & Dangl",
"Hoffman & Dangl", "Hoffman & Dangl", "Hoffman & Dangl", "Hoffman & Dangl",
"Hoffman & Dangl", "Hoffman & Dangl", "Bunch", "Bunch", "Bunch")
###With this I create the values for the forest plot###
TE2<-c(NA, -0.05, 0.27, 0.39, 0.21, 0, 0.08, 0.28, 0.23, -0.16, 0.11, 0.13,
0.03, 0.78, 0.43, 0.07, 0.34, 0.58, NA, NA)
Inferior2<-c(NA, -0.55, -0.22, -0.11, -0.3, -0.31, -0.22, -0.03, -0.07, -0.47,
-0.19, -0.18, -0.27, 0.46, 0.12, -0.55, -0.07, 0.15, NA, NA)
Superior2<-c(NA, 0.44, 0.76, 0.88, 0.73, 0.31, 0.39, 0.6, 0.54, 0.15, 0.42, 0.45,
0.34, 1.11, 0.74, 0.69, 0.75, 1.02, NA, NA)
###With this I create the sidetable###
tabletext<-cbind(
c("Autor", Autor, NA, "Summary"),
c("Effect Size", TE, NA, NA),
c("Inferior", Inferior, NA, NA),
c("Superior", Superior, NA, "0.17"))
# Add this!
TE2[20] <- .17
Inferior2[20] <- TE2[20] - .3
Superior2[20] <- TE2[20] + .3
###With this I create the forestplot###
forestplot(tabletext,
hrzl_lines = gpar(col="#444444"),
mean = TE2, lower = Inferior2, upper = Superior2,
new_page = TRUE,
xlog=FALSE,
is.summary=c(TRUE, rep(FALSE,18), TRUE),
graph.pos=5,
boxsize=0.2,
col=fpColors(box="black",line="black", summary="black"))
我必须做一个森林图和边表,但我必须使用效应大小而不是使用优势比(像往常一样)。我根据在 Internet 上找到的另一个代码编写了这段代码,因为我需要 forestplot 和 sidetable。我编辑了我的问题以包含示例数据和我的部分解决方案。
library(forestplot)
####With this I create the data for the tabletext###
TE<-as.character(c(-0.05, 0.27, 0.39, 0.21, 0, 0.08, 0.28, 0.23, -0.16, 0.11, 0.13,
0.03, 0.78, 0.43, 0.07, 0.34, 0.58))
Inferior<-as.character(c(-0.55, -0.22, -0.11, -0.3, -0.31, -0.22, -0.03, -0.07, -0.47,
-0.19, -0.18, -0.27, 0.46, 0.12, -0.55, -0.07, 0.15))
Superior<-as.character(c(0.44, 0.76, 0.88, 0.73, 0.31, 0.39, 0.6, 0.54, 0.15, 0.42,
0.45, 0.34, 1.11, 0.74, 0.69, 0.75, 1.02))
Autor<-c("Cain & Smith", "Cain & Smith", "Cain & Smith", "Cain & Smith",
"Hoffman & Dangl", "Hoffman & Dangl", "Hoffman & Dangl", "Hoffman & Dangl",
"Hoffman & Dangl", "Hoffman & Dangl", "Hoffman & Dangl", "Hoffman & Dangl",
"Hoffman & Dangl", "Hoffman & Dangl", "Bunch", "Bunch", "Bunch")
###With this I create the values for the forest plot###
TE2<-c(NA, -0.05, 0.27, 0.39, 0.21, 0, 0.08, 0.28, 0.23, -0.16, 0.11, 0.13,
0.03, 0.78, 0.43, 0.07, 0.34, 0.58, NA, NA)
Inferior2<-c(NA, -0.55, -0.22, -0.11, -0.3, -0.31, -0.22, -0.03, -0.07, -0.47,
-0.19, -0.18, -0.27, 0.46, 0.12, -0.55, -0.07, 0.15, NA, NA)
Superior2<-c(NA, 0.44, 0.76, 0.88, 0.73, 0.31, 0.39, 0.6, 0.54, 0.15, 0.42, 0.45,
0.34, 1.11, 0.74, 0.69, 0.75, 1.02, NA, NA)
###With this I create the sidetable###
tabletext<-cbind(
c("Autor", Autor, NA, "Summary"),
c("Effect Size", TE, NA, NA),
c("Inferior", Inferior, NA, NA),
c("Superior", Superior, NA, "0.17"))
###With this I create the forestplot###
forestplot(tabletext,
hrzl_lines = gpar(col="#444444"),
mean = TE2, lower = Inferior2, upper = Superior2,
new_page = TRUE,
xlog=FALSE,
is.summary=c(TRUE, rep(FALSE,18), TRUE),
graph.pos=5,
boxsize=0.2,
col=fpColors(box="black",line="black", summary="black"))
我以前的问题是生成的森林图将效果大小向上移动了一行(因此,它们与边桌上的信息不匹配,因为从列标题级别开始)。现在,我唯一的问题是它没有将摘要添加到情节中。
非常感谢您的帮助!
您的问题是您没有将摘要信息添加到均值、上限和下限置信区间:
library(forestplot)
####With this I create the data for the tabletext###
TE<-as.character(c(-0.05, 0.27, 0.39, 0.21, 0, 0.08, 0.28, 0.23, -0.16, 0.11, 0.13,
0.03, 0.78, 0.43, 0.07, 0.34, 0.58))
Inferior<-as.character(c(-0.55, -0.22, -0.11, -0.3, -0.31, -0.22, -0.03, -0.07, -0.47,
-0.19, -0.18, -0.27, 0.46, 0.12, -0.55, -0.07, 0.15))
Superior<-as.character(c(0.44, 0.76, 0.88, 0.73, 0.31, 0.39, 0.6, 0.54, 0.15, 0.42,
0.45, 0.34, 1.11, 0.74, 0.69, 0.75, 1.02))
Autor<-c("Cain & Smith", "Cain & Smith", "Cain & Smith", "Cain & Smith",
"Hoffman & Dangl", "Hoffman & Dangl", "Hoffman & Dangl", "Hoffman & Dangl",
"Hoffman & Dangl", "Hoffman & Dangl", "Hoffman & Dangl", "Hoffman & Dangl",
"Hoffman & Dangl", "Hoffman & Dangl", "Bunch", "Bunch", "Bunch")
###With this I create the values for the forest plot###
TE2<-c(NA, -0.05, 0.27, 0.39, 0.21, 0, 0.08, 0.28, 0.23, -0.16, 0.11, 0.13,
0.03, 0.78, 0.43, 0.07, 0.34, 0.58, NA, NA)
Inferior2<-c(NA, -0.55, -0.22, -0.11, -0.3, -0.31, -0.22, -0.03, -0.07, -0.47,
-0.19, -0.18, -0.27, 0.46, 0.12, -0.55, -0.07, 0.15, NA, NA)
Superior2<-c(NA, 0.44, 0.76, 0.88, 0.73, 0.31, 0.39, 0.6, 0.54, 0.15, 0.42, 0.45,
0.34, 1.11, 0.74, 0.69, 0.75, 1.02, NA, NA)
###With this I create the sidetable###
tabletext<-cbind(
c("Autor", Autor, NA, "Summary"),
c("Effect Size", TE, NA, NA),
c("Inferior", Inferior, NA, NA),
c("Superior", Superior, NA, "0.17"))
# Add this!
TE2[20] <- .17
Inferior2[20] <- TE2[20] - .3
Superior2[20] <- TE2[20] + .3
###With this I create the forestplot###
forestplot(tabletext,
hrzl_lines = gpar(col="#444444"),
mean = TE2, lower = Inferior2, upper = Superior2,
new_page = TRUE,
xlog=FALSE,
is.summary=c(TRUE, rep(FALSE,18), TRUE),
graph.pos=5,
boxsize=0.2,
col=fpColors(box="black",line="black", summary="black"))