ggplot2、tikzDevice、knitr を連携させるのに問題があります。私は RStudio を使用しており、いくつかの R グラフィックスを Latex ドキュメントに含めようとしています。私は非常に単純な例を使用しました:
\documentclass{article}
\begin{document}
\begin{figure}
<<fig1,eval=TRUE,echo=FALSE,dev='tikz'>>=
library(ggplot2)
library(tikzDevice)
qplot(displ, hwy, data = mpg, colour = factor(cyl))
@
\end{figure}
\end{document}
しかし、pdf が出力されず、次のエラー メッセージが表示されます。
Error in getMetricsFromLatex(TeXMetrics) :
TeX was unable to calculate metrics for the following string
or character:
hwy
Common reasons for failure include:
* The string contains a character which is special to LaTeX unless
escaped properly, such as % or $.
* The string makes use of LaTeX commands provided by a package and
the tikzDevice was not told to load the package.
The contents of the LaTeX log of the aborted run have been printed above,
it may contain additional details as to why the metric calculation failed.
Calls: knit ... widthDetails.text -> grid.Call -> <Anonymous> -> getMetricsFromLatex
Execution halted
この問題はここで扱われましたが、提案された解決策は私にはうまくいきません。何か案が?