RNW文件不会在pdf中生成图 [英] Rnw file doesn't generate plot in pdf
本文介绍了RNW文件不会在pdf中生成图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用 .Rnw
文件,试图生成绘图.但是,当我单击编译PDF"时,我得到一个空白的pdf,其中仅包含图形标题,没有图.看起来像这样:
I'm working with an .Rnw
file, trying to generate a plot. However, when I click Compile PDF, I get a blank pdf with just the figure caption and no plot. It looks like this:
这是代码:
\documentclass{article}
\begin{document}
<<fasfd, fig.height=10, fig.cap="first", fig.pos="t", echo=FALSE, fig.width=10>>=
barplot(table(mtcars$gear))
@
\end{document}
我在做什么错了?
推荐答案
Sweave
不提供像 knitr
那样多的选项.要包含具有 sweave
的图,您需要指定 fig = TRUE
Sweave
does not provide so many options as knitr
. To include plots with sweave
you need to specify fig= TRUE
\documentclass{article}
\begin{document}
\SweaveOpts{concordance=TRUE}
Without $fig=TRUE$
<<fasfd, fig.height=5, fig.cap="first", fig.pos="t", echo=TRUE, fig.width=10>>=
barplot(table(mtcars$gear))
@
With $fig=TRUE$
<<fig=TRUE>>=
barplot(table(mtcars$gear))
@
A boxplot of the \emph{airquality} data:
\centering
<<fig=TRUE, echo=FALSE>>=
data(airquality)
boxplot(Ozone ~ Month, data = airquality)
@
\end{document}
这篇关于RNW文件不会在pdf中生成图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文