Sweave in Rstudio — no plots showing in pdf

大兔子大兔子 提交于 2021-02-17 06:47:08

问题


Sweave/Latex newbie here. I have no problems generating regular functions outputs, but the plots don't show up. Here's a basic example:

\documentclass{article}
\begin{document}
\SweaveOpts{concordance=TRUE}

<<chunk1>>=
print("Hello World")
boxplot(rnorm(100))
@

\end{document}

And the corresponding .tex output:

\documentclass{article}
\usepackage{Sweave}
\begin{document}
\input{test2-concordance}

\begin{Schunk}
\begin{Sinput}
> print("Hello World")
\end{Sinput}
\begin{Soutput}
[1] "Hello World"
\end{Soutput}
\begin{Sinput}
> boxplot(rnorm(100))
\end{Sinput}
\end{Schunk}

\end{document}

I am running Rstudio version 0.98.501. I use Texlive, and tried on both Windows and Linux with the same results. What am I missing?


回答1:


You need to put fig=TRUE in the hook. It should look like:

<<chunk1,fig=TRUE>>=

Then try again!!



来源:https://stackoverflow.com/questions/23233761/sweave-in-rstudio-no-plots-showing-in-pdf

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!