Last chance! 50% off unlimited learning
Sale ends in
A driver for Sweave
extending the standard driver
Rtangle
with additional code chunk options.
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", ...)
Named list
of five functions; see Sweave
or the ‘Sweave User Manual’ vignette in the utils
package.
Name of Sweave source file. See the description of the
corresponding argument of Sweave
.
An object of class SweaveSyntax
. See
Rtangle
.
Name of output file used unless split = TRUE
.
See Rtangle
.
Split output into a file for each code chunk?
Logical to suppress all progress messages.
See Rtangle
.
If TRUE
, the code chunk is ignored
entirely.
An alternative way to set both ignore.on.weave
of RweaveExtraLatex
and ignore.on.tangle
.
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.
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
.
Vincent Goulet, based on work by Friedrich Leisch and R-core.
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.
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