50% off | Unlimited Data & AI Learning

Last chance! 50% off unlimited learning

Sale ends in


RweaveExtra (version 1.2-0)

RtangleExtra: 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 = TRUE, chunk.sep = "\n\n", ...)

Value

Named list of five functions; see Sweave

or the ‘Sweave User Manual’ vignette in the utils

package.

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 TRUE, the default extension of Rtangle is used (the ‘engine’, usually R). If FALSE, no extension is added to the file name.

chunk.sep

Text to use as separator between code chunks. The default value reproduces the output of the standard Rtangle driver. If FALSE, no separator is added between chunks.

...

See RweaveLatex.

Author

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

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.

The argument chunk.sep offers control over the chunk separator that the standard Rtangle driver does not. The chunk separator is added before all chunks, except the first one. Therefore, no chunk separator follows the last chunk. No newline (aka ‘line feed’) is added to the value of the argument. Using control characters (e.g. \n) in a code chunk option is not supported.

See Also

RweaveExtraLatex, Rtangle, Sweave.

Examples

Run this code
testfile <- system.file("examples", "example-extra.Rnw",
                        package = "RweaveExtra")
# \dontshow{
oldwd <- setwd(tempdir()) # write only to a temp directory
# }

## 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")

## Reduce to spacing between code chunks to a single
## blank line
Stangle(testfile, driver = RtangleExtra(), chunk.sep = "\n")
if (interactive()) file.show("example-extra.R")

## The effect of 'chunk.sep=FALSE' in the second chunk
## is more interesting without the annotations
Stangle(testfile, driver = RtangleExtra(),
        annotate = FALSE, chunk.sep = "\n")
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")
if (!interactive()) unlink(c("example-extra*", "hello.sh"))
setwd(oldwd)

Run the code above in your browser using DataLab