首页 > 解决方案 > R包“forestplot”:错误消息re:从输入矩阵中识别上/下边界

问题描述

我会很感激你的帮助。我正在使用 forestplot R 包来创建森林图。进展顺利。

library(forestplot)                  
test_data <- data.frame(
    coef = c(1.53, 1.56, 1.11, 1.35, 1.00, 0.94, 1.03),
    low = c(1.43, 1.38, 1.08, 1.05, 0.91, 0.87, 0.95),
    high = c(1.64, 1.76, 1.15, 1.75, 1.10, 1.01, 1.11),
    boxsize = c(0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1)
)
row_names <- cbind(
    c("Variable", "BMI", "WHR", "Diabetes", "Insulin resistance", "LDL", "HDL", "ApoB"),
    c("SNPs", "807", "368", "386", "53", "213", "510", "241"),
    c("OR (95% CI)", "1·53 (1·43−1·64)", "1·56 (1·38−1·76)", "1·11 (1·08−1·15)", "1·35 (1·05−1·75)", "1·00 (0·91−1·10)", "0·94 (0·87−1·01)", "1·03 (0·95−1·11)"),
    c("p-value", "6·72E−35", "2·90E−12", "6·61E−10", "0·02", "0·97", "0·083", "0·53")
)
test_data <- rbind(rep(NA, 3), test_data)
forestplot(
    labeltext = row_names,
    xlab = "Odds ratio",
    test_data[, c("coef", "low", "high")],
    is.summary = FALSE,
    boxsize = test_data$boxsize,
    zero = 1,
    cex = 0.1,
    align = TRUE,
    xlog = FALSE,
    graphwidth = unit(1.5, "snpc"),
    col = fpColors(lines = "royalblue", box = "darkblue")
)

我一直在一次添加一个变量,并在添加每个变量后绘制我的图表,以确保每个步骤都没有引入错误。一切都很顺利,直到我添加了我的第八个变量“甘油三酯”及其相关数字:

library(forestplot)                  
test_data <- data.frame(
    coef = c(1.53, 1.56, 1.11, 1.35, 1.00, 0.94, 1.03, 1.15),
    low = c(1.43, 1.38, 1.08, 1.05, 0.91, 0.87, 0.95, 1.07),
    high = c(1.64, 1.76, 1.15, 1.75, 1.10, 1.01, 1.11, 1.11),
    boxsize = c(0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1)
)
row_names <- cbind(
    c("Variable", "BMI", "WHR", "Diabetes", "Insulin resistance", "LDL", "HDL", "ApoB", "Triglycerides"),
    c("SNPs", "807", "368", "386", "53", "213", "510", "241", "427"),
    c("OR (95% CI)", "1·53 (1·43−1·64)", "1·56 (1·38−1·76)", "1·11 (1·08−1·15)", "1·35 (1·05−1·75)", "1·00 (0·91−1·10)", "0·94 (0·87−1·01)", "1·03 (0·95−1·11)", "1·15 (1·07−1·11)"),
    c("p-value", "6·72E−35", "2·90E−12", "6·61E−10", "0·02", "0·97", "0·083", "0·53", "2·14E−4")
)
test_data <- rbind(rep(NA, 3), test_data)
forestplot(
    labeltext = row_names,
    xlab = "Odds ratio",
    test_data[, c("coef", "low", "high")],
    is.summary = FALSE,
    boxsize = test_data$boxsize,
    zero = 1,
    cex = 0.1,
    align = TRUE,
    xlog = FALSE,
    graphwidth = unit(1.5, "snpc"),
    col = fpColors(lines = "royalblue", box = "darkblue")
)

添加这第八个变量时,我现在收到以下错误消息:

prFpConvertMultidimArray(mean) 中的错误:抱歉,未能正确识别输入矩阵的上/下边界。

我在这里找不到语法错误,我真的不知道为什么这才刚刚发生。任何建议将不胜感激。

谢谢你。

标签: rforestplot

解决方案


推荐阅读