绘制多组森林图报错
Error in check_errors(data = data, est = est, lower = lower, upper = upper, :
All the elements in estimate, lower and upper should have the same length
In addition: Warning messages:
1: Unknown or uninitialised column: `Up_1`.
2: Unknown or uninitialised column: `Up_2`.
我的代码
sub_total<-read_xlsx("../AHF-analysis-sfw/sub/sub_total.xlsx")
subgps <- c(2,3,5,6,8,9,11,12,14,15,17,18,20,21,23,24,26,27,29,30)# 指定要缩进的亚组,此处向量中的数字表示亚组的行数
sub_total$Group[subgps] <- paste(" ",sub_total$Group[subgps])
# 将 NA 转为空白或转换为对应字符
sub_total$n1 <- ifelse(is.na(sub_total$asthma), " ", sub_total$asthma)
sub_total$n2 <- ifelse(is.na(sub_total$non_asthma), " ", sub_total$non_asthma)
# 为 CI 添加空白列
sub_total$`total` <- paste(rep(" ", 30), collapse = " ")
sub_total$`industrial` <- paste(rep(" ", 30), collapse = " ")
sub_total$`traffic` <- paste(rep(" ", 30), collapse = " ")
sub_total$`building` <- paste(rep(" ", 30), collapse = " ")
sub_total$`body` <- paste(rep(" ", 30), collapse = " ")
# 设置主题
tm <- forest_theme(base_size = 10,
refline_lty = "solid",
ci_pch = c(15, 18),
ci_col = c("#377eb8", "#4daf4a"),
footnote_col = "blue",
legend_name = "Group",
legend_value = c("Trt 1", "Trt 2"),
vertline_lty = c("dashed", "dotted"),
vertline_col = c("#d6604d", "#bababa"))
p <- forest(sub_total[,c(1, 29, 30, 31, 32, 33, 34, 35)],
est = list(sub_total$`OR_t`,
sub_total$`OR_1`,
sub_total$`OR_2`,
sub_total$`OR_3`,
sub_total$`OR_4`),
lower = list(sub_total$Low_t,
sub_total$Low_1,
sub_total$Low_2,
sub_total$Low_3,
sub_total$Low_4),
upper = list(sub_total$Up_t,
sub_total$Up_1,
sub_total$Up_2,
sub_total$Up_3,
sub_total$Up_4),
ci_column = c(4, 5, 6, 7, 8),
ref_line = 1,
vert_line = c(0.5, 2),
nudge_y = 0.2,
theme = tm)
plot(p)
问题出在哪里呢 求解(大哭)