I have been working on the ideas and scripts introduced in this previous post. The result is a new set of scripts packaged in this latexR.tar.gz file.
The main enhancements are the following:
- An environment can be assigned to each chunk, see
?environment
inR
. Dependencies are established only across those variables that are evaluated in the same environment. In this way, the names of variables can be reused without generating false dependencies. For example, two chunks may use the same variable namedx
, but both chunks may actually be independent of each other. This avoid having to come up with new names, such asx2
, and remember all of them. - The
R
functionall.vars
is now used. This facilitates the detection of the variables created and used by each chunk, which is in turn used to determine dependencies across files. -
Before, the output was placed after the whole
R
input chunk. When the chunk prints the value of more than one object, it may not be clear what each output refers to in the code chunk. Now, output is arranged by default in between input code in the same order as it would be printed on the console.
These are the arguments that can be passed to the new command latexr
:
-
make
: generate/update and run the Makefile. The following values can be passed to it:doc=x
, the name of the file without extension (assumed ‘.rnw’),Rdir=x
, the name of the directory where the R chunks will be stored,figDir=x
, the name of the directory where the figures will be placed.
-
clean
: deleteLaTeX
andR
auxiliary and output files. -
reload
: reload.Rprofile
(if any). -
clear
: delete.R
and.Rout
files evaluated in a given environment. -
help
: brief description of available arguments and options.
A sample rnw
file and output is available here. The output pdf file is built by means of the following command (after installling latexr
): latexr make
.
At the moment the documentation is a bit short. Don’t hesitate to contact me if you need some clarifications on the usage of these scripts.