R 使用latex2exp::TeX使用方程式注释使用ggplot2绘制的绘图
我的目标是通过使用包latex2exp 例如,给定方程式:R 使用latex2exp::TeX使用方程式注释使用ggplot2绘制的绘图,r,ggplot2,latex,annotate,R,Ggplot2,Latex,Annotate,我的目标是通过使用包latex2exp 例如,给定方程式: eqn <- "$\\textbf{Volume}(ml) = 0.035 \\cdot \\textbf{CSA}(mm^2) + 0.127 \\cdot \\textbf{age}(months) - 7.8$" 我的示例代码失败,错误如下: Error in stats::complete.cases(df[, vars, drop = FALSE]) : invalid 'type' (expression) o
eqn <- "$\\textbf{Volume}(ml) = 0.035 \\cdot \\textbf{CSA}(mm^2) + 0.127 \\cdot \\textbf{age}(months) - 7.8$"
我的示例代码失败,错误如下:
Error in stats::complete.cases(df[, vars, drop = FALSE]) :
invalid 'type' (expression) of argument
我做错了什么?一个有效的解决方案,基于:
Error in stats::complete.cases(df[, vars, drop = FALSE]) :
invalid 'type' (expression) of argument
ggplot(mpg, aes(x = displ, y = hwy)) +
geom_point() +
annotate("text", x=3, y=40, label=TeX(eqn, output="character"),
hjust=0, size = 4, parse = TRUE)