我想用一个简单的方程注释 ggplot 图。下面的代码可以做到这一点,但它会引发有关应用 is.na() 的警告:
library(ggplot2)
ggplot() +
annotate(geom = "text", x = 1, y = 1,
label = expression(paste(beta, pi, "(1-" , pi, ")")),
hjust = "left")
Warning message:
In is.na(x) : is.na() applied to non-(list or vector) of type 'expression'
在没有警告的情况下包含表达式的正确语法是什么?
为什么这不能使警告消失?
suppressWarnings(
ggplot() +
annotate(geom = "text", x = 1, y = 1,
label = expression(paste(beta, pi, "(1-" , pi, ")")),
hjust = "left")
)
我正在使用 R 版本 4.0.2 和 ggplot2 版本 3.3.2