这是一个系统的回顾,所以我只能分析以前的论文提供的数据。对于七个这样的情况,有足够的数据可以构建CI,我希望以通常的森林图方式呈现,包括根据CI的长度调整方框大小的吸引人的特征。
对于第八个样本-这里标记为尴尬-因为样本量没有显示出来,我只能显示平均值(最好是在同一个森林样地上),而不能显示CI。所以,我需要帮助来调整下面的代码,以便在不扭曲其他七个of框的大小的情况下,将此平均值显示为图上的单个点。
关于为尴尬添加一个极窄的CI :要么CI太窄,R舍入值,导致没有方框显示,要么CI太窄,以至于森林图形库将其解释为“确定”的东西,并赋予它最高权重(因此是一个非常大的方框),这反过来会导致所有其他方框变得难以区分地小,并有损于目的。一位学生还考虑了为尴尬分配一个非常大的CI --这给了尴尬一个小方框,并保持其他状态相对成比例,尽管尴尬OR的上下界的“胡须”变得很长。
在显示中强制实现所需效果的一种方法可能是为笨拙声明一个非常大的CI (减轻权重),并以白色/透明(因此不可见)打印CI行;我不知道如何做到这一点。(正如您可能已经猜到的那样,我绝对是一个初学者。)
library(forestplot)
# grafted from https://cran.r-project.org/web/packages/forestplot/vignettes/forestplot.html
##According to this Awkward doesn't have a confidence interval; entries of 0.1 and 30 are fictitious
Table1_19225_OR <-
structure(list(
mean = c(NA, NA, 6, 4.19, 3.11, 3.79, 13.20, 3.84, 2.32, 5.78, NA, 4.41, 5.99, 5.43),
lower = c(NA, NA, 0.1, 2.54, 1.39, 1.83, 6.25, 2.69, 1.04, 2.89, NA, 3.13, 4.65, 4.79),
upper = c(NA, NA, 30, 6.91, 6.96, 7.85, 27.87, 5.49, 5.2, 11.54, NA, 6.23, 7.71, 6.14)),
.Names = c("mean", "lower", "upper"),
row.names = c(NA, -14L),
class = "data.frame")
#State data pooled using random effects model
tabletext<-cbind(
c("", "State", "Awkward", "Okay1", "Okay2", "Okay3", "Okay4", "Okay5", "Okay6", "Okay7", NA, "State data", "National", "National"),
c("Change", "Year", "1977", "1977", "1977", "1982", "1989", "1997", "2000", "2012", NA, "", "1995-2003", "2005-2008"),
c("Odds", "Ratio", "6.00", "4.19", "3.11", "3.89", "13.20", "3.84", "2.32", "5.78", NA, "4.41", "5.99", "5.43"))
forestplot(tabletext,
hrzl_lines = gpar(col="#444444"),
Table1_19225_OR, new_page = TRUE,
is.summary=c(TRUE,TRUE,rep(FALSE,9),TRUE,FALSE,FALSE), #TRUE means bold
clip=c(2, 14),
ci.vertices = TRUE,
xlog=FALSE,
xticks = c(2.0, 4.0, 6.0, 8.0, 10, 12),
grid=TRUE,
xlab="95% CIs for Odds Ratio",
col=fpColors(box="royalblue",line="darkblue", summary="royalblue"))字体大小更改
own <- fpTxtGp() own #检查默认值是什么--我认为每次调用forestplot库own$xlab$cex <- 1.25 #默认值是1,不确定这是什么单位所以反复试验own$legend$cex <- 0.8 #默认值是0.8,更改此值似乎不会更改forestplot own$ticks$cex <- 0.8 #默认值是0.5,更改CI刻度上的数字大小
发布于 2019-03-25 04:45:22
由于您不能真正知道场景中的置信区间,因此我认为最简单的方法是修改置信区间函数,以处理缺少数据的绘制值。在下面的示例中,我检查了下半部分或上半部分中的NA,如果找不到,我将绘制一个grid.circle,而不是fpDrawnormalCI使用的grid.rect。
library(forestplot)
fn <- function(...,
y.offset = 0.5,
lower_limit, estimate, upper_limit,
clr.marker){
if (is.na(lower_limit) || is.na(upper_limit)) {
grid.circle(x = unit(estimate, "native"), y = y.offset,
r = unit(.1, "snpc"),
gp = gpar(fill = clr.marker, col = clr.marker))
} else {
# Forward otherwise to the default function
fpDrawNormalCI(...,
y.offset = y.offset,
lower_limit = lower_limit,
estimate = estimate,
upper_limit = upper_limit,
clr.marker = clr.marker)
}
}
# grafted from https://cran.r-project.org/web/packages/forestplot/vignettes/forestplot.html
##According to this Awkward doesn't have a confidence interval; entries of 0.1 and 30 are fictitious
Table1_19225_OR <-
structure(list(
mean = c(NA, NA, 6, 4.19, 3.11, 3.79, 13.20, 3.84, 2.32, 5.78, NA, 4.41, 5.99, 5.43),
lower = c(NA, NA, NA, 2.54, 1.39, 1.83, 6.25, 2.69, 1.04, 2.89, NA, 3.13, 4.65, 4.79),
upper = c(NA, NA, NA, 6.91, 6.96, 7.85, 27.87, 5.49, 5.2, 11.54, NA, 6.23, 7.71, 6.14)),
.Names = c("mean", "lower", "upper"),
row.names = c(NA, -14L),
class = "data.frame")
#State data pooled using random effects model
tabletext<-cbind(
c("", "State", "Awkward", "Okay1", "Okay2", "Okay3", "Okay4", "Okay5", "Okay6", "Okay7", NA, "State data", "National", "National"),
c("Change", "Year", "1977", "1977", "1977", "1982", "1989", "1997", "2000", "2012", NA, "", "1995-2003", "2005-2008"),
c("Odds", "Ratio", "6.00", "4.19", "3.11", "3.89", "13.20", "3.84", "2.32", "5.78", NA, "4.41", "5.99", "5.43"))
forestplot(tabletext,
Table1_19225_OR,
fn.ci_norm = fn,
hrzl_lines = gpar(col="#444444"),
new_page = TRUE,
is.summary=c(TRUE,TRUE,rep(FALSE,9),TRUE,FALSE,FALSE), #TRUE means bold
clip=c(2, 14),
ci.vertices = TRUE,
xlog=FALSE,
xticks = c(2.0, 4.0, 6.0, 8.0, 10, 12),
grid=TRUE,
xlab="95% CIs for Odds Ratio",
col=fpColors(box="royalblue",line="darkblue", summary="royalblue"))这就是情节本身:

https://stackoverflow.com/questions/55095501
复制相似问题