I am working with knitr, polymode, ess and I would like to export just the R code from my .Rnw into a .R file. A basic file might look something like this:


My Rnw file 

##This is some R code 


In the end, I would like an R file with just

##This is some R code

1 Answer 1


In R, tangling is implemented via knitr::purl and utils::Stangle.

ESS provides an interface to these commands. See the variable ess-swv-processor and the ess-swv-weave function (bound to M-n s in Rnw-mode).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.