It is simply horrible, if not impossible, to extend the standard Sweave function in base R, because it is poorly modularized in design and hard-coded in many places. Existing packages:
brew is fairly light-weighted, and I like its simple style as well as its PHP-like nature (use <% %> instead of <<>>= @ and the awkward \Sexpr{})
pgfSweave features beauty, which is extremely important to me; tikzDevice is an awesome package
cacheSweave features cache, of course, and it is important to large-scale computation
decumar is great in design; we no longer need to "ruin" the LaTeX document by weird illegal home-made nonsense pseudo-LaTeX code, since it puts literate programming code in LaTeX comments
What is my ideal Sweave package?
we should be able to specify the pattern of R code to execute by ourselves; why? because literate programming with R should not be restricted to a particular type of output like LaTeX, HTML, or any other files; I want to borrow the design of decumar to put Sweave-related stuff in comments, but each language has its own definition of comments (may begin with % or <!--, ...); for example, <!-- first-chunk, source=abc.R, noecho, figure, width=5, height=4 --> is used in an HTML page to refer to a code chunk in an R script abc.R which looks like ## <label>:first-chunk
beside putting R code in the main file (probably as comments), we can also put R code in an R script and use a label to reference a code chunk in the main file, which brings us huge convenience that we can run the R code whenever we want (imagine how difficult it is to run R code in LyX/Sweave without compiling the whole document!!), and this makes Stangle a useless invention (code is separated with the main file, so no need to export code again)
issues that may be difficult
parse options, especially for plots
recursive weaving, e.g. parse files under \input{}
misc issues
output should not be mangled with the leading prompts like > and + by default; that is too bad for other people trying to copy and run your code
should be able to freely specify the styles to be applied to the input code and output (instead of hard-coded Schunk, Sinput, ...); this can be convenient for HTML output since it gives us the flexibility to use CSS
should not expect the users to print() grid-based graphics; make it natural that they just feel like they typed the commands in R (qplot() alone should produce the plot; why expect me to print(qplot()) in Sweave?); I believe this is one of the ideas in evaluate
how about a package name knit?
Finally, I need time and I wish other Sweave users may find the above ideas useful and like to contribute.
It is simply horrible, if not impossible, to extend the standard Sweave function in base R, because it is poorly modularized in design and hard-coded in many places. Existing packages:
brew
is fairly light-weighted, and I like its simple style as well as its PHP-like nature (use<% %>
instead of<<>>= @
and the awkward\Sexpr{}
)pgfSweave
features beauty, which is extremely important to me;tikzDevice
is an awesome packagecacheSweave
features cache, of course, and it is important to large-scale computationdecumar
is great in design; we no longer need to "ruin" the LaTeX document by weird illegal home-made nonsense pseudo-LaTeX code, since it puts literate programming code in LaTeX commentsWhat is my ideal Sweave package?
decumar
to put Sweave-related stuff in comments, but each language has its own definition of comments (may begin with%
or<!--
, ...); for example,<!-- first-chunk, source=abc.R, noecho, figure, width=5, height=4 -->
is used in an HTML page to refer to a code chunk in an R scriptabc.R
which looks like## <label>:first-chunk
Stangle
a useless invention (code is separated with the main file, so no need to export code again)\input{}
>
and+
by default; that is too bad for other people trying to copy and run your codeSchunk
,Sinput
, ...); this can be convenient for HTML output since it gives us the flexibility to use CSSprint()
grid-based graphics; make it natural that they just feel like they typed the commands in R (qplot()
alone should produce the plot; why expect me toprint(qplot())
in Sweave?); I believe this is one of the ideas inevaluate
knit
?Finally, I need time and I wish other Sweave users may find the above ideas useful and like to contribute.