[ESS] knitr

Yihui Xie xie at yihui.name
Tue Oct 2 23:05:57 CEST 2012


There is 100% guarantee for *.Rnw documents; one thing I can think of
is to see if opts_chunk is used in the document, e.g.
opts_chunk$set(echo = TRUE). This is unique to knitr. Other minor
differences are like results='hide' (knitr) vs results=hide (Sweave).

If a document uses \usepackage{Sweave}, it is more likely to be Sweave
because knitr does not need this. The other approach is to check if
(require('knitr')) in R before weaving the file.

*.Rmd/*.Rhtml documents should be unique to knitr, though.

Regards,
Yihui
--
Yihui Xie <xieyihui at gmail.com>
Phone: 515-294-2465 Web: http://yihui.name
Department of Statistics, Iowa State University
2215 Snedecor Hall, Ames, IA


On Tue, Oct 2, 2012 at 3:57 PM, Stephen Eglen <S.J.Eglen at damtp.cam.ac.uk> wrote:
>> I have just added knitr processor for Rnw files to the trunk. That is,
>> there is a customizable ess-swv-processor variable, which, if set to
>> 'knitr, makes "M-n s" to knit instead of Sweave, and "M-n T" to purl
>> instead of Stangle.
>>
>> There are also specialized ess-swv-knit and ess-swv-purl bound to "M-n
>> r" and "M-n u" exactly as in the above add-on by Simon Potter.
>
> Thanks Vitalie!
>
> Is there a reliable way of discriminating a Sweave file from a knitr
> file?  If so, it could be used to set this variable
> (ess-swv-processor).  However, I can think of only
>
> \usepackage{Sweave}
>
> and that is not foolproof (e.g. \RequirePackage is similar).
>
> I'm in a transition period -- I have several Sweave files, and think
> knitr is more flexible, so currently am writing new docs in knitr.
>
> Stephen
>
>



More information about the ESS-help mailing list