From mtmorgan at fredhutch.org  Thu Nov 13 13:25:02 2014
From: mtmorgan at fredhutch.org (Martin Morgan)
Date: Thu, 13 Nov 2014 04:25:02 -0800
Subject: [Rd] Changing style for the Sweave vignettes
In-Reply-To: <CA+A1kV4FSFtUMDPME0_MEMM_orCX+U9jgUZ9m1_rT0-ftRE4Fg@mail.gmail.com>
References: <CA+A1kV4FSFtUMDPME0_MEMM_orCX+U9jgUZ9m1_rT0-ftRE4Fg@mail.gmail.com>
Message-ID: <5464A31E.2030608@fredhutch.org>

On 11/13/2014 03:09 AM, January Weiner wrote:
> As a user, I am always annoyed beyond measure that Sweave vignettes
> precede the code by a command line prompt. It makes running examples
> by simple copying of the commands from the vignette to the console a
> pain. I know the idea is that it is clear what is the command, and
> what is the output, but I'd rather precede the output with some kind
> of marking.
>
> Is there any other solution possible / allowed in vignettes? I would
> much prefer to make my vignettes easier to use for people like me.

Vignettes do not need to be generated by Sweave and to pdf documents. My current 
favorite (e.g., recent course material at 
http://bioconductor.org/help/course-materials/ which uses styling from the 
BiocStyle package 
http://bioconductor.org/packages/release/bioc/html/BiocStyle.html) uses the 
knitr package (see http://yihui.name/knitr/) to produce HTML vignettes (knitr 
will also process Rnw files to pdf with perhaps more appealing styling, see, 
e.g.,  http://bit.ly/117OLVl for an example of PDF output).

The mechanics are discussed in Writing R Extensions (RShowDoc('R-exts')), 
section 1.4.2 Non-Sweave vignettes. There are three steps involved: specifying a 
\VignetteEngine in the vignette itself, specifying VignetteBuilder: field in the 
DESCRIPTION file, and including the package providing the engine (knitr, in my 
case) in the Suggests: field of the DESCRIPTION file.

Brian mentioned processing the vignette to it's underlying code; see 
?browseVignettes and ?vignette for installed packages, and ?Stangle in R and R 
CMD Stangle for extracting the R code from stand-alone vignettes to .R files.

Martin Morgan

>
> Kind regards,
>
> j.
>


-- 
Computational Biology / Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N.
PO Box 19024 Seattle, WA 98109

Location: Arnold Building M1 B861
Phone: (206) 667-2793



[Rd] Changing style for the Sweave vignettes
Martin Morgan