R-在林图上显示≥/大于或等于

时间:2019-03-23 19:43:43

标签: r text forestplot

我为forestplot准备了代码,但是我在导出带有“≥” /更多或等号的绘图时遇到了问题。

library(forestplot)
names6 <- c("Variable",
           "A ≥ 4000***",
           "B ≥ 50***",
           "C**",
           "D",
           "E***",
           "F",
           "G*",
           "H**",
           "I*",
           "J***")

coef6 <- c(0.42, 1.58, 1.35, 0.49,
           0.46, 0.66, 0.62, 1.34, 0.52, 0.72)

low6 <- c(0.34, 1.29, 1.08, 0.21,
          0.33, 0.44, 0.43, 1.08, 0.29, 0.61)

high6 <- c(0.51, 1.93, 1.69, 1.21,
           0.64, 0.99, 0.91, 1.66, 0.92, 0.86)
boxsize6 <-c(0.2, 0.2, 0.2,0.2,
             0.2,0.2, 0.2,0.2,
             0.2, 0.2)
test_data <- data.frame(coef=coef6,
                        low=low6,
                        high=high6,
                        boxsize=boxsize6)
row_names <- cbind(names6,
                   c("OR",test_data$coef), c("CI-95%",  test_data$low), c("CI+95%", test_data$high) )
test_data <- rbind(NA, test_data)


#####FIGURE
forestplot(labeltext = row_names,
           mean = test_data$coef, upper = test_data$high,
           lower = test_data$low,
           is.summary=c(TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE),
           boxsize = test_data$boxsize,
           zero = 1,
           xlog = FALSE,
           xlab = "OR (95% CI)",
           col = fpColors(lines="black", box="black"),
           ci.vertices = TRUE,
           xticks = c(0,0.5, 1, 1.5, 2.0),
           colgap = unit(0.03,'npc'),
           lineheight = unit(1.1,"cm"),
           txt_gp=fpTxtGp(label = gpar(cex = 0.8),
                          title = gpar(cex = 1),
                          ticks = gpar(cex = 0.6),
                          xlab = gpar(cex = 0.7)))

但是,我无法将绘图导出为具有当前“≥” /更多或相等值的.pdf文件。

相反,我得到了“ =“ /等号。 我该如何更改才能在情节上获得此标志?

编辑: \ u2265不起作用...

1 个答案:

答案 0 :(得分:1)

此解决方案可能是特定于系统的。这是在Windows上可以使用的功能:

library("forestplot")
library("withr")

names6 <- c("Variable",
            "A \u2265 4000***",
            "B \u2265 50***",
            "C**",
            "D",
            "E***",
            "F",
            "G*",
            "H**",
            "I*",
            "J***")

### Data & params code here....

with_cairo_pdf('forestplot.pdf',

  ### Forest plot code here....
  forestplot(labeltext = row_names,
             ....)
)