[R] Troubleshooting sweave
Brian Diggs
diggsb at ohsu.edu
Fri Nov 12 02:22:40 CET 2010
On 11/11/2010 3:42 PM, sachinthaka.abeywardana at allianz.com.au wrote:
>
> Hi All,
>
> I've reproduced the example from Prof. Friedrich Leisch's webpage. When I
> write sweave("Example-1.Snw") OR sweave("Example-1.Rnw"), (yes, I renamed
> them). I get the following error:
>
> Writing to file example-1.tex
> Processing code chunks ...
> 1 : echo term verbatim
>
> Error: chunk 1
> Error in library(ctest) : there is no package called 'ctest'
That error message indicates that you attempted to load a package
('ctest') that is not installed. Normally, you would just need to
install the package using the install.package() command. However, there
is (no longer) a ctest package to install. Digging through the email
archives, it appears to have been merged into the stats package back in
version 1.9.0. So you can just delete the "library(ctest)" line in the
Rnw file.
You can search for examples that are more recent; this one must have
been from before April 2004 (when R 1.9.0 was released). Though I don't
blame you for being confused; I would also have expected the examples on
what seems to be the canonical homepage to work and not be out-of-date.
> Also while I'm at it, is there an R command to compile the tex file as a
> pdf or does the Sweave() function do that for me?
Check out the texi2dvi() function in the tools package. If you want a
PDF, be sure to use the pdf option.
> Thanks,
> Sachin
> p.s. sorry about the corporate notice.
>
> example-1.Rnw: from http://www.statistik.lmu.de/~leisch/Sweave/
>
> \documentclass[a4paper]{article}
>
> \title{Sweave Example 1}
> \author{Friedrich Leisch}
>
> \begin{document}
>
> \maketitle
>
> In this example we embed parts of the examples from the
> \texttt{kruskal.test} help page into a \LaTeX{} document:
>
> <<>>=
> data(airquality)
> library(ctest)
> kruskal.test(Ozone ~ Month, data = airquality)
> @
> which shows that the location parameter of the Ozone
> distribution varies significantly from month to month. Finally we
> include a boxplot of the data:
>
> \begin{center}
> <<fig=TRUE,echo=FALSE>>=
> boxplot(Ozone ~ Month, data = airquality)
> @
> \end{center}
>
> \end{document}
--
Brian S. Diggs, PhD
Senior Research Associate, Department of Surgery
Oregon Health & Science University
More information about the R-help
mailing list