I have an rsweave file that I run almost twice a week. Last time I used it a change a couple of things and when I run it to compile to pdf I got the following errors:
The pdf compiles complitly, and the only thing I notice that the error did is that the the pdf output has a extra page (the first one) all blank. I don't know how to make a reproducible example of the errors because I don't know whats the cause of it. But any way I just want to know generally how to debug a rsweave file when getting latex error like the ones in the picture
How to debug a Rsweave
525 Views Asked by Alejandro Andrade At
1
You don't say how you are running
Sweave, but that looks like RStudio. To debug something like this, just runSweaveexplicitly in the R console, e.g. if your input file issource.Rnw, runThis will produce
source.tex. Open that file in a text editor and look at the start of it. You will see that\Schunkis used on line 27, but\begin{document}doesn't occur until sometime later.My guess is that you added some text or a code chunk to the header. All text belongs after
\begin{document}.Edited to add: It turns out from the comments below that you were using
print(...)in a code chunk before\begin{document}. In Sweave,printoutput goes into the document. If you want a message to show up in the console log but not the document, usemessage("some text"). You'll also need to suppress the echoing of the command if you want to do this in the document header. For example,will result in something like this in your console log:
and nothing in the document.