Search code examples
rlatexrstudiosweave

How to pause Sweave Compilation in Rstudio to check variables


I've inherited a sweave file from a different author. I'd like to pause it after it finishes running the R code to interrogate the variables and see the objects in the console before it goes to PDF generation.

Is there a way to do this Rstudio conveniently? Or even in emacs if I must?

Thanks!


Solution

  • For debugging or checking Sweave documents, run the file through Stangle, e.g.

    Stangle("a.rnw")

    This produces a pure R-file, which you can debug separately. If the tangled files runs ok, but the Sweave'd does not, it is almost always due to some \Sexpr{} expression. These are difficult to locate, the error messages can be highly confusing.