| SweaveGetSourceName {utils} | R Documentation |
File Processed by Sweave or Stangle
Description
Extract the name of the file currently processed by
Sweave or Stangle in a
non-interactive session.
Usage
SweaveGetSourceName()
Details
The function returns the name of the source file being processed by
Sweave or Stangle when the tool is invoked from the
command line through either:
an expression passed to
R -eorRscript -e;-
R CMD SweaveorR CMD Stangle.
In the first scenario, the filename must be the first, unnamed
argument to Sweave or Stangle.
This function cannot be used from an interactive R session.
Value
Filename as a character string.
Author(s)
Vincent Goulet
Examples
nmRnw <- "example-4.Rnw"
exfile <- system.file("Sweave", nmRnw, package = "utils")
## Check the contents of the file
if (interactive()) file.show(exfile)
## Sweave the file in a separate process
expr <- paste0("Sweave('", exfile, "', ",
"encoding = 'utf-8')")
system2("R", c("-e", paste0("\"", expr, "\"")))
## View the LaTeX file
nmtex <- sub("Rnw$", "tex", nmRnw)
if (interactive()) file.show(nmtex)
## Stangle was called from within Sweave in the file
nmR <- sub("Rnw$", "R", nmRnw) # default R output file name
if (interactive()) file.show(nmR)
## Repeat using 'R CMD Sweave'
system2("R", c("CMD", "Sweave", exfile, "--encoding=utf-8"))
if (interactive()) file.show(nmtex)
if (interactive()) file.show(nmR)
## Do not use the function interactively
## Not run: SweaveGetSourceName()
[Package utils version 4.6.0 Index]