I have the following R code
<<Q1b1, fig=TRUE>>=
qqnorm(resid(model1), main=NULL)
@
and I would like to add the option [keepaspectratio=true, scale = 0.75] to the \includegraphics{} call so that the above R code chunk generates
\begin{figure}[ht]
\caption{}
\begin{center}
\includegraphics[keepaspectratio=true, scale = 0.75]{filename.pdf}
\label{fig:1}
\end{center}
\end{figure}
I know you can specify the width and height using \SweaveOpt{width=x, height=y} but I want to specify the scale and have it keep the aspect ratio of the figure when it's generated.
Is there an easy way to do this?
Thanks
If you do not have
\usepackage{Sweave}
in your Sweave file preamble, it will be inserted automatically as the last line before the\begin{document}
statement. Therefore you need to put, which is actually the default of Sweave style file as specified in
\usepackage{Sweave}
.AFTER the
\begin{document}
statement. See Sweave document (http://www.statistik.lmu.de/~leisch/Sweave/Sweave-manual.pdf) section 4.1.2 for detail.You can set the width for every figure in your Sweave document with
\setkeys{Gin}
instruction. For example, the following in the preamble of your document makes every figure width 80% of the text width on your page :Otherwise you can add the
include=FALSE
argument to your code chunk and then create the\includegraphics
instruction manually. By default, if your Sweave file is calledtest.Rnw
, then the name of the pdf file generated by the code chunk will betest-Q1b1.pdf
. So you can do something like :However, I've made some tests on your example but the
scale
parameter doesn't seem to have any effect on the figure here. Others likeangle
do, though.