这是系统的综述,因此我只能分析以前的论文提供的数据。对于七个这样的数据,有足够的数据可以用来构造CI,我希望以通常的森林图方式展示它,其中包括根据CI的长度调整框大小的诱人功能。
对于第八个(这里标记为“尴尬”),因为没有显示样本数量,所以我只能(最好在同一林地上)显示平均值,而不能显示CI。因此,在调整下面的代码时,我需要帮助,以便将该平均值表示为绘图上的单个点,而不会扭曲其他七个“确定”框的大小。
在为Awkward添加极窄的CI时:CI太窄并且R将值四舍五入导致没有显示框,或者CI太窄以至于森林图库将其解释为“确定”的事物,并且给它最大的重量(所以是一个非常大的盒子),这反过来会使所有其他盒子变得很小而无法达到目的。一名学生还考虑为“尴尬”分配一个非常大的配置项-这给“尴尬”分配了一个小盒子,并使其他状态保持相对比例,尽管“尴尬”上下限的“胡须”变得很长。
在显示中强制达到预期效果的一种方法可能是要求Awkward拥有非常大的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() 自己的#checking以查看默认值是什么-我认为每次调用forestplot库时都会加载这些默认值 own $ xlab $ cex <-1.25#默认为1,不确定这东西是什么试错单位 own $ legend $ cex <-0.8#默认为0.8,更改此值似乎不会更改forestplot上的任何内容 own $ ticks $ cex <-0.8#默认为0.5,更改CI刻度上数字的大小
答案 0 :(得分:0)
由于您实际上并不了解方案中的置信区间,我认为最简单的方法是简单地修改置信区间函数以处理缺少数据的绘图值。在下面的示例中,我在下部或上部检查NA
,如果找不到,我绘制了grid.circle
而不是grid.rect
使用的fpDrawnormalCI
。
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"))
这是情节本身: