clean_lyx {svSweave} | R Documentation |
Clean up, weave or tangle Sweave files produced by LyX with the SciViews Sweave module
Description
These functions process .Rnw`` files produced by LyX and the SciViews Sweave module (not the standard Sweave module provided with LyX <= 2.0.0!). The SciViews-LyX extension defines
rchunk' commands to contain R chunks
(embedded R code processed by Sweave). Unfortunately, LyX use to write two
lines feeds for each line of code, introducing extra lines in the R chunks.
Moreover, tabulations are interpreted as 8 spaces, while R code use to
consider a tabulation as equivalent to 4 spaces. clean_lyx()
corrects
these little problems, and it should not affect R noweb files produced by a
different software.
Usage
clean_lyx(RnwCon, RnwCon2 = RnwCon, encoding = "UTF-8")
cleanLyxRnw(RnwCon, RnwCon2 = RnwCon, encoding = "UTF-8")
tangle_lyx(
file,
driver = Rtangle(),
syntax = getOption("SweaveSyntax"),
encoding = "UTF-8",
width = 80,
useFancyQuotes = TRUE,
annotate = TRUE,
logFile = file.path(tempdir(), ".lyxSweave.log"),
...
)
tangleLyxRnw(
file,
driver = Rtangle(),
syntax = getOption("SweaveSyntax"),
encoding = "UTF-8",
width = 80,
useFancyQuotes = TRUE,
annotate = TRUE,
logFile = file.path(tempdir(), ".lyxSweave.log"),
...
)
purl_lyx(
file,
encoding = "UTF-8",
width = 80,
useFancyQuotes = TRUE,
logFile = file.path(tempdir(), ".lyxSweave.log"),
...
)
purlLyxRnw(
file,
encoding = "UTF-8",
width = 80,
useFancyQuotes = TRUE,
logFile = file.path(tempdir(), ".lyxSweave.log"),
...
)
weave_lyx(
file,
driver = RweaveLatex(),
syntax = getOption("SweaveSyntax"),
encoding = "UTF-8",
width = 80,
useFancyQuotes = TRUE,
logFile = file.path(tempdir(), ".lyxSweave.log"),
...
)
weaveLyxRnw(
file,
driver = RweaveLatex(),
syntax = getOption("SweaveSyntax"),
encoding = "UTF-8",
width = 80,
useFancyQuotes = TRUE,
logFile = file.path(tempdir(), ".lyxSweave.log"),
...
)
knit_lyx(
file,
encoding = "UTF-8",
width = 80,
useFancyQuotes = TRUE,
logFile = file.path(tempdir(), ".lyxSweave.log"),
...
)
knitLyxRnw(
file,
encoding = "UTF-8",
width = 80,
useFancyQuotes = TRUE,
logFile = file.path(tempdir(), ".lyxSweave.log"),
...
)
Arguments
RnwCon |
A connection object or a character string corresponding to the path to a R noweb file to be read. |
RnwCon2 |
Idem, but where the cleaned up R noweb file should be written (by default, on the same file or connection). |
encoding |
The encoding of the |
file |
The Sweave source file. |
driver |
The actual function to do the process, see |
syntax |
|
width |
The width used for outputs, 80 characters by default. |
useFancyQuotes |
Do we use fancy quotes in R outputs? |
annotate |
Is the R code extracted from the |
logFile |
The file to use to log results of weaving/tangling the document. |
... |
Further arguments passed to the driver's setup function of
|
Value
For clean_lyx()
, a list for Sweave options found in the document; NULL
for the other functions: these functions are invoked for their side effects.
The function weave_lyx()
uses the standard Sweave driver (but it uses knitr
for LyX documents that use the SciViews Knitr module), while knit_lyx()
does the same, but using the knitr driver. Similarly, purl_lyx()
is the
knitr counterpart of tangle_lyx()
standard tangling function.
Author(s)
Philippe Grosjean
See Also
knitr::knit()
, utils::Sweave()