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