[R] SWEAVE - a gentle introduction

Duncan Murdoch murdoch.duncan at gmail.com
Wed Nov 18 01:05:05 CET 2015


On 17/11/2015 6:56 PM, Henrik Bengtsson wrote:
> When choosing source format, it's probably helpful to know that if you
> work with a Markdown-based format (e.g. Rmarkdown) you'll be able to
> generate either/both HTML or/and PDF documents, whereas if you work
> with LaTeX-based formats (e.g. Sweave/knitr) you will only be able
> output PDF documents (at least without great efforts).
>
> One major advantage with HTML documents/reports is that they aren't
> constrained by page breaks, e.g. you don't have to worry about
> generating long tables that run across two or more pages. With LaTeX
> that is often a great pain.  These days even mathematical equations
> renders quite well in HTML.  I tend to use HTML output for everyday
> analysis reports and PDF occasionally for more final artifacts such as
> supplementary notes where I want to have full control of layout,
> equations, figure sizes and bibliographies.
>
> If you plan to write package vignettes using one of the above formats,
> choice of vignette format does not matter these days.  They're all
> equally easy to use and incorporate in packages.

Yes, I agree with everything you say.  One additional thing:  I've been 
working on the rgl package lately (for movable 3D graphics); it is 
possible to embed those in a PDF document, but not portably (i.e. the 
PDF viewer will matter); it is much easier to embed rgl graphics in 
HTML.  So I tend to use Markdown input through knitr (which calls 
Rmarkdown).

Duncan Murdoch

>
> Cheers,
>
> Henrik
>
> On Tue, Nov 17, 2015 at 11:09 AM, Duncan Murdoch
> <murdoch.duncan at gmail.com> wrote:
>> On 17/11/2015 10:42 AM, Marc Schwartz wrote:
>>>
>>>
>>>> On Nov 17, 2015, at 9:21 AM, John Sorkin <jsorkin at grecc.umaryland.edu>
>>>> wrote:
>>>>
>>>> I am looking for a gentle introduction to SWEAVE, and would appreciate
>>>> recommendations.
>>>> I have an R program that I want to run and have the output and plots in
>>>> one document. I believe this can be accomplished with SWEAVE. Unfortunately
>>>> I don't know HTML, but am willing to learn. . . as I said I need a gentle
>>>> introduction to SWEAVE.
>>>> Thank you,
>>>> John
>>>>
>>>
>>>
>>> John,
>>>
>>> A couple of initial comments.
>>>
>>> First, you will likely get some recommendations to also consider using
>>> Knitr:
>>>
>>>     http://yihui.name/knitr/
>>>
>>> which I do not use myself (I use Sweave), but to be fair, is worth
>>> considering as an alternative.
>>
>>
>> He did, and I'd agree with them.  I've switched to knitr for all new
>> projects and some old ones.  knitr should be thought of as Sweave version 2.
>>
>> Duncan Murdoch
>>
>>
>>>
>>> Second, to create stand alone documents, as opposed to web based content,
>>> you will likely want the output to be in TeX/LaTeX via Sweave, which can
>>> then become PDF based documents via the post processing of the TeX/LaTeX
>>> source. That is what I do for all of my analytic deliverables. You can also
>>> use LaTeX classes like 'Beamer' to create Powerpoint-like slides for
>>> presentation.
>>>
>>> Fritz' web site for Sweave is here:
>>>
>>>     http://www.statistik.lmu.de/~leisch/Sweave/
>>>
>>> and there are some links to supporting materials there with very basic
>>> examples.
>>>
>>> Another resource is:
>>>
>>>     https://beckmw.files.wordpress.com/2014/02/sweave_intro1.pdf
>>>
>>> and if you Google for Sweave Introductions and Tutorials, there are a
>>> myriad of others.
>>>
>>> In conjunction with Sweave itself, there are a variety of supporting
>>> packages on CRAN that have related functionality (e.g. formatted LaTeX
>>> output) that are worth knowing about and are included in the Reproducible
>>> Research task view:
>>>
>>>     https://cran.r-project.org/web/views/ReproducibleResearch.html
>>>
>>> Regards,
>>>
>>> Marc Schwartz
>>>
>>> ______________________________________________
>>> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>> PLEASE do read the posting guide
>>> http://www.R-project.org/posting-guide.html
>>> and provide commented, minimal, self-contained, reproducible code.
>>>
>>
>> ______________________________________________
>> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list