[ESS] knitr

Yihui Xie xie at yihui.name
Wed Oct 3 15:13:20 CEST 2012


I think a less intrusive way is to be able to set the R function as

(if (require('knitr')) knit else Sweave)

This is more flexible than choosing between knitr and sweave, e.g. the
user can set some global options before knit (like
opts_chunk$set(tidy=FALSE))

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 Wed, Oct 3, 2012 at 4:37 AM, Vitalie Spinu <spinuvit at gmail.com> wrote:
>   >> Yihui Xie <xie at yihui.name>
>   >> on Tue, 2 Oct 2012 16:05:57 -0500 wrote:
>
>   > 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.
>
> A bit of a problem is that ess-swv-processor is a custom variable, and
> is not good to mess with it programmaticaly. It's not good to ignore it
> either if opts_chunk is present or knitr is loaded.
>
> To relatively quickly switch the processor one can do M-x set-variable RET
> ess-s-pro TAB RET 'knitr RET. Alternatively people can just use
> specialized shortcuts M-n r and M-n u, not a big deal.
>
>
> [...]
>
>   >>
>   >> 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.
>
> Yes, knitr is so much, much better and easier. Thanks Yihui. It's our
> job now to correctly leverage the full power of knitr in ESS.
>
>     Vitalie



More information about the ESS-help mailing list