森林图中的列名和行名
col and row names in a Forest plot
我不知道如何将列名和行名引入森林图中。这是数据集:
structure(list(structure(c(5L, 6L, 4L, 3L, 2L, 1L), .Label = c("Austria",
"Denmark", "England", "France", "Portugal", "Spain"), class = "factor"),
Slope = c(-1.8511, -2.33305, -2.698, -1.46, -0.98, -1.401
), low = c(-3.3021, -4.305, -5.873, -4.86, -5.082, -2.887
), high = c(-0.4008, -0.364, -0.087, 2.98, 3.125, -0.054),
bS0 = c(-5.66, -2.709, -4.057, -1.224, -0.574, -1.43), Sf = c(0.354,
0.169, 0.253, 0.077, 0.036, 0.089), `S0-Sf` = c(0.146, 0.126,
0.169, 0.091, 0.061, 0.088)), .Names = c("", "Slope", "low",
"high", "bS0", "Sf", "S0-Sf"), class = "data.frame", row.names = c(NA,
-6L))
这里是获取森林图的脚本:
windows()
forestplot(labeltext=data, graph.pos=3,
mean=c(data$Slope),
lower=c(data$low), upper=c(data$high),
xlab="Regression Coefficient",
txt_gp=fpTxtGp(label=gpar(cex=1),
ticks=gpar(cex=1),
xlab=gpar(cex = 1),
title=gpar(cex = 1)),
col=fpColors(box="black", lines="black", zero = "gray50"),
zero=0, cex=0.9, lineheight = "auto", boxsize=0.1,
lwd.ci=1, ci.vertices=TRUE, ci.vertices.height = 0.1,colgap=unit(4,"mm"))
结果如下:
但是,我想介绍国家名称(我的数据的第 1 列)和列名称。我应该怎么做?
我不知道如何修改你的解决方案,所以我按照我的方式做了:
data <-
structure(list(
coef = c(NA,-1.85110, -2.33305, -2.69800, -1.46000, -0.98000, -1.40100),
low = c(NA,-3.3021, -4.3050, -5.8730, -4.8600, -5.0820, -2.8870),
high = c(NA,-0.4008, -0.3640, -0.0870, 2.9800, 3.1250, -0.0540)),
.Names = c("coef", "low", "high"),
row.names = c(NA, -7L),
class = "data.frame")
tabletext<-cbind(c(NA,"Portugal","Spain","France","Engald","Denmark","Austria"),
c("Slope", "-1.8511", "-2.33305", "-2.698", "-1.46", "-0.98", "-1.401"),
c("low", "-3.3021", "-4.305", "-5.873", "-4.86", "-5.082", "-2.887"),
c("high", "-0.4008", "-0.364", "-0.087", "2.98", "3.125", "-0.054"),
c("bS0", "-5.66", "-2.709", "-4.057", "-1.224", "-0.574", "-1.43"),
c("Sf", "-0.354", "0.169", "0.253", "0.077", "0.036", "0.089"),
c("S0-Sf", "0.146", "0.126", "0.169", "0.091", "0.061", "0.088"))
forestplot(tabletext,
data,new_page = TRUE,
clip=c(-6,3),
boxsize = .25,
graphwidth = unit(10, "cm"),
xlog=F,
col=fpColors(line="black"),
xlab="Regression Coefficient")
您需要在 forestplot
函数中使用 graph.pos
参数。
例如,如果您想要斜率列之后的绘图,请使用 graph.position=3
我不知道如何将列名和行名引入森林图中。这是数据集:
structure(list(structure(c(5L, 6L, 4L, 3L, 2L, 1L), .Label = c("Austria",
"Denmark", "England", "France", "Portugal", "Spain"), class = "factor"),
Slope = c(-1.8511, -2.33305, -2.698, -1.46, -0.98, -1.401
), low = c(-3.3021, -4.305, -5.873, -4.86, -5.082, -2.887
), high = c(-0.4008, -0.364, -0.087, 2.98, 3.125, -0.054),
bS0 = c(-5.66, -2.709, -4.057, -1.224, -0.574, -1.43), Sf = c(0.354,
0.169, 0.253, 0.077, 0.036, 0.089), `S0-Sf` = c(0.146, 0.126,
0.169, 0.091, 0.061, 0.088)), .Names = c("", "Slope", "low",
"high", "bS0", "Sf", "S0-Sf"), class = "data.frame", row.names = c(NA,
-6L))
这里是获取森林图的脚本:
windows()
forestplot(labeltext=data, graph.pos=3,
mean=c(data$Slope),
lower=c(data$low), upper=c(data$high),
xlab="Regression Coefficient",
txt_gp=fpTxtGp(label=gpar(cex=1),
ticks=gpar(cex=1),
xlab=gpar(cex = 1),
title=gpar(cex = 1)),
col=fpColors(box="black", lines="black", zero = "gray50"),
zero=0, cex=0.9, lineheight = "auto", boxsize=0.1,
lwd.ci=1, ci.vertices=TRUE, ci.vertices.height = 0.1,colgap=unit(4,"mm"))
结果如下:
但是,我想介绍国家名称(我的数据的第 1 列)和列名称。我应该怎么做?
我不知道如何修改你的解决方案,所以我按照我的方式做了:
data <-
structure(list(
coef = c(NA,-1.85110, -2.33305, -2.69800, -1.46000, -0.98000, -1.40100),
low = c(NA,-3.3021, -4.3050, -5.8730, -4.8600, -5.0820, -2.8870),
high = c(NA,-0.4008, -0.3640, -0.0870, 2.9800, 3.1250, -0.0540)),
.Names = c("coef", "low", "high"),
row.names = c(NA, -7L),
class = "data.frame")
tabletext<-cbind(c(NA,"Portugal","Spain","France","Engald","Denmark","Austria"),
c("Slope", "-1.8511", "-2.33305", "-2.698", "-1.46", "-0.98", "-1.401"),
c("low", "-3.3021", "-4.305", "-5.873", "-4.86", "-5.082", "-2.887"),
c("high", "-0.4008", "-0.364", "-0.087", "2.98", "3.125", "-0.054"),
c("bS0", "-5.66", "-2.709", "-4.057", "-1.224", "-0.574", "-1.43"),
c("Sf", "-0.354", "0.169", "0.253", "0.077", "0.036", "0.089"),
c("S0-Sf", "0.146", "0.126", "0.169", "0.091", "0.061", "0.088"))
forestplot(tabletext,
data,new_page = TRUE,
clip=c(-6,3),
boxsize = .25,
graphwidth = unit(10, "cm"),
xlog=F,
col=fpColors(line="black"),
xlab="Regression Coefficient")
您需要在 forestplot
函数中使用 graph.pos
参数。
例如,如果您想要斜率列之后的绘图,请使用 graph.position=3