pgfSweave (version 1.3.0)

pgfSweave: Quality speedy graphics compilation and caching for Sweave

Description

pgfSweave provides a number of improvements to the speed and quality of Sweave output including: (1) capabilities for 'caching' graphics generated with Sweave on top of the caching mechanisms provided by cacheSweave, (2) an interface to the tikzDevice package which provides graphics with consistent font style, sizing and quality as the main document and (3) highlighting of echo'd source code via the highlight package. pgfSweave provides a new driver for Sweave (pgfSweaveDriver) with new chunk options tikz, external, sanitize, highlight and tidy on top of the cache option provided by cacheSweave.

Usage

pgfSweave(file, compile.tex = TRUE, graphics.only = FALSE, pdf = T, syntax = getOption("SweaveSyntax"), np = 2, ...)

Arguments

file
A connection or a character string giving the name of the file to load.
compile.tex
If TRUE run LaTeX/pdfLaTeX on the resulting tex file. If FALSE only run Sweave.
graphics.only
If TRUE Only run Sweave and then the commands to externalize graphics, don\'t call texi2dvi to do the final compilation.
pdf
Passed to texi2dvi. If TRUE (default) then generate a pdf file otherwise generate a dvi file.
syntax
An object of class SweaveSyntax or a character string with its name. The default installation provides SweaveSyntaxNoweb and SweaveSyntaxLatex (passed to Sweave).
np
The number of parallel processes to use for graphics externalization.
...
Other options to be passed to texi2dvi

Value

A pdf file is generated if compile.tex=TRUE and a tex file only is generated otherwise.

Details

This package provides new features beyond cacheSweave:
  1. better recognition of code chunk changes
  2. the 'caching' of code chunks which generate graphics and
  3. an interface to the tikzDevice package for the generation of graphics in which the font matches that of the main document.

The process carried out by pgfSweave involves:

  • Running Sweave on the .Rnw file using pgfSweaveDriver function.
  • Generating a graphics file from each newly created or changed graphic.
  • Running the pgf externalization commands for each newly generated graphic (via a makefile).
  • Finally running LaTeX with on the .tex file using the real job name.

For more details see the pgfSweave package vignette.

References

Sweave manual: http://www.statistik.lmu.de/~leisch/Sweave/Sweave-manual.pdf

cacheSweave vignette: http://cran.r-project.org/web/packages/cacheSweave/vignettes/cacheSweave.pdf

pgf manual externalization section: http://sourceforge.net/projects/pgf/

See Also

pgfSweaveDriver, Sweave, tikzDevice cacheSweave

Examples

Run this code
## Not run: vignette("pgfSweave")

## Not run: 
# library(pgfSweave)
# oldcwd <- getwd()
# dir <- tempdir()
# setwd(dir)
# file.copy(system.file("example","pgfSweave-example.Rnw", package = "pgfSweave"),dir)
# file <- file.path(dir,"pgfSweave-example.Rnw")
# pgfSweave(file,compile.tex=FALSE)
# setwd(oldcwd)
# ## End(Not run)

## Not run: 
# ## Normally to compile to PDF by
# #    pgfSweave("pgfSweave-example.Rnw")
# # Default as of version 1.2 is pdf=T
# #
# # or use
# #
# # R CMD pgfsweave pgfSweave-example.Rnw
# ## From the command line which calls texi2dvi (default uses pdflatex)
# #
#  unix
# ## NOTE: LaTeX may not be included in your path by default when using the R
# ## GUI, please see the FAQ in the pgfSweave vignette if your latex or pdflatex
# ## are not found.
#  windows
# ## WINDOWS USERS: This has only been tested with MiKTeX
# 
# ## Use pgfSweave outside of R with the script provided in the pgfSweave exec/ directory
# ## End(Not run)

Run the code above in your browser using DataCamp Workspace