Package 'RweaveExtra'

Title: Sweave Drivers with Extra Tricks Up their Sleeve
Description: Weave and tangle drivers for Sweave extending the standard drivers. RweaveExtraLatex and RtangleExtra provide options to completely ignore code chunks on weaving, tangling, or both. Chunks ignored on weaving are not parsed, yet are written out verbatim on tangling. Chunks ignored on tangling may be evaluated as usual on weaving, but are completely left out of the tangled scripts. The driver RtangleExtra also provides an option to specify the extension of the file name (or remove it entirely) when splitting is selected on tangling.
Authors: Vincent Goulet [cre, aut], R Core Team [aut] (Code from the original Sweave drivers)
Maintainer: Vincent Goulet <[email protected]>
License: GPL (>= 2)
Version: 1.1-0
Built: 2024-11-17 02:53:04 UTC
Source: https://github.com/cran/RweaveExtra

Help Index


Sweave Drivers with Extra Tricks Up their Sleeve

Description

Weave and tangle drivers for Sweave extending the standard drivers. RweaveExtraLatex and RtangleExtra provide options to completely ignore code chunks on weaving, tangling, or both. Chunks ignored on weaving are not parsed, yet are written out verbatim on tangling. Chunks ignored on tangling may be evaluated as usual on weaving, but are completely left out of the tangled scripts. The driver RtangleExtra also provides an option to specify the extension of the file name (or remove it entirely) when splitting is selected on tangling.

Details

The RweaveExtraLatex and RtangleExtra drivers extend the standard Sweave drivers RweaveLatex and Rtangle, respectively. They are selected through the driver argument of Sweave.

The drivers provide additional options to completely ignore code chunks on weaving, tangling, or both. Chunks ignored on weaving are not parsed and are written out verbatim on tangling. Chunks ignored on tangling are processed as usual on weaving, but completely left out of the tangled scripts. The driver RtangleExtra also provides the option extension to specify the extension of the file name (or remove it entirely) when splitting is selected.

In a literate programming workflow, the additional options allow to include code chunks in a file such as:

  • code that is not parsable by R (say, because of errors inserted for educational purposes);

  • code in another programming language entirely (say, a shell script to start an analysis);

  • code for a Shiny app.

With the standard drivers, using option eval = FALSE results in code being commented out in tangled scripts files. Chunks may be omitted on tangling with drop.evalFALSE = TRUE, but only provided the chunk is not evaluated on weaving. Therefore, the standard drivers have no provision to either omit a chunk on weaving and tangle it as is, or to process a chunk on weaving but omit it on tangling.

Author(s)

Vincent Goulet [cre, aut], R Core Team [aut] (Code from the original Sweave drivers)

Maintainer: Vincent Goulet <[email protected]>


R Driver for Stangle with Additional Options

Description

A driver for Sweave extending the standard driver Rtangle with additional code chunk options.

Usage

RtangleExtra()

RtangleExtraSetup(file, syntax, output = NULL, annotate = TRUE,
                  split = FALSE, quiet = FALSE, drop.evalFALSE = FALSE,
                  ignore.on.tangle = FALSE, ignore = FALSE,
                  extension = NULL, ...)

Arguments

file

Name of Sweave source file. See the description of the corresponding argument of Sweave.

syntax

An object of class SweaveSyntax. See Rtangle.

output

Name of output file used unless split = TRUE. See Rtangle.

annotate

A logical or function. See Rtangle.

split

Split output into a file for each code chunk?

quiet

Logical to suppress all progress messages.

drop.evalFALSE

See Rtangle.

ignore.on.tangle

If TRUE, the code chunk is ignored entirely.

ignore

An alternative way to set both ignore.on.weave of RweaveExtraLatex and ignore.on.tangle.

extension

Extension to use for the file name, without the leading dot, when splitting is selected. If NULL, the default extension of Rtangle is used (the ‘engine’, usually ‘R’). If FALSE, no extension is added to the file name.

...

See RweaveLatex.

Details

Chunks ignored on tangling are not written out to script files, but they are processed normally on weaving (unless ignore = TRUE). Therefore, chunks may still use eval = TRUE for weaving purposes, yet not be tangled.

The argument extension is specially useful with ignore.on.weave = TRUE of RweaveExtraLatex to include code or text that the engine would not be able to parse.

Value

Named list of five functions; see Sweave or the ‘Sweave User Manual’ vignette in the utils package.

Author(s)

Vincent Goulet, based on work by Friedrich Leisch and R-core.

See Also

RweaveExtraLatex, Rtangle, Sweave.

Examples

testfile <- system.file("examples", "example-extra.Rnw",
                        package = "RweaveExtra")


## Check the contents of the file
if (interactive()) file.show(testfile)

## Tangle the file in the current working directory
Stangle(testfile, driver = RtangleExtra())

## View tangled file
if (interactive()) file.show("example-extra.R")

## Use 'extension=sh' with 'ignore.on.weave=TRUE', and
## the options 'split=TRUE' and 'prefix=FALSE' of Stangle
## to extract the shell script to a file 'hello.sh'
Stangle(testfile, driver = RtangleExtra(),
        split = TRUE, annotate = FALSE)
if(interactive()) file.show("hello.sh")

R/LaTeX Driver for Sweave with Additional Options

Description

A driver for Sweave extending the standard driver RweaveLatex with additional code chunk options.

Usage

RweaveExtraLatex()

RweaveExtraLatexSetup(file, syntax, output = NULL, quiet = FALSE,
                      debug = FALSE, stylepath, ignore.on.weave = FALSE,
                      ignore = FALSE, ...)

Arguments

file

Name of Sweave source file. See the description of the corresponding argument of Sweave.

syntax

An object of class SweaveSyntax. See RweaveLatex.

output

Name of output file. See RweaveLatex.

quiet

If TRUE all progress messages are suppressed. See RweaveLatex.

debug

If TRUE, input and output of all code chunks is copied to the console. See RweaveLatex.

stylepath

See RweaveLatex.

ignore.on.weave

If TRUE, the code chunk is ignored entirely, i.e., neither parsed nor evaluated.

ignore

An alternative way to set both ignore.on.weave and ignore.on.tangle of RtangleExtra.

...

See RweaveLatex.

Details

Chunks ignored on weaving are not parsed and are not evaluated, but they are written out on tangling as normal code chunks (unless ignore=TRUE).

If ignore.on.weave or ignore is FALSE, the code chunk is processed using the standard driver RweaveLatex with its options.

Value

Named list of five functions; see Sweave or the ‘Sweave User Manual’ vignette in the utils package.

Author(s)

Vincent Goulet, based on work by Friedrich Leisch and R-core.

See Also

RtangleExtra, RweaveLatex, Sweave.

Examples

testfile <- system.file("examples", "example-extra.Rnw", package = "RweaveExtra")


## Check the contents of the file
if(interactive()) file.show(testfile)

## Weave, then tangle the file in the current working directory
Sweave(testfile, driver = RweaveExtraLatex())
Stangle(testfile, driver = RtangleExtra())

## View weaved and tangled files
if(interactive()) file.show("example-extra.tex")
if(interactive()) file.show("example-extra.R")