Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/74.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 使用latex2exp::TeX使用方程式注释使用ggplot2绘制的绘图_R_Ggplot2_Latex_Annotate - Fatal编程技术网

R 使用latex2exp::TeX使用方程式注释使用ggplot2绘制的绘图

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

我的目标是通过使用包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) 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)