Sweave processing of Open Document Format files
the ODF file created using OpenOffice V2.0 or above.
path to put the processed file (should include file name and extension)
a path to a directory where the source file will be unpacked and processed. If it does not exist, it will be created. If it exists, it should be empty, since all its contents will be included in the generated file.
a list of control settings. See
odfWeave can be used to embed R code within a word processing
odfWeave package was created so that the
Sweave can be used within a rich editor like
OpenOffice. The generated document can also easily be edited.
The markup language used is the Open Document Format (ODF), which is an
open, non–proprietary format that encompasses text documents,
presentations and spreadsheets. There are several editors/office suites
that can produce ODF files. OpenOffice, as of version 2.0, uses ODF as
the default format.
has been tested with OpenOffice to produce text documents. As of the
odfWeave processing of presentations and
spreadsheets should be considered to be experimental (but should be
supported in subsequent versions).
Since ODF files are compressed archives of files and directories, R
will need to zip and unzip the source file. While R has an unzip
utility, it does not have one for re-zipping files, so an external
application is needed.
zip are free utilities located at
jar can be used. See
odfWeaveControl for more
information on configuring
odfWeave to use applications other than
A few notes about file paths and working directories:
When specifying the location of the odt file, you cannot use relative paths such as
file = "../file.odt". If the input or output files are not in the current working directory, then the absolute path should be used
odfWeave changes the working directory to the location where the odt file is decompressed. If an error occurs within
odfWeave, the working directory will be changed back to the original path
odfWeave changes the working directory when the code chunks are executed, references to files and directories should use absolute paths. For example, if you are using
read.csv to bring data into R, the file specification should include the whole path since the working directory will have been changed to a temporary location
The functionality of
Sweave is mostly preserved in
odfWeave, such as weaving, hooks, figure environments, etc. Some
functionality, such as writing output to separate files for each code
chunk using the
split argument, doesn't make sense when using
RweaveOdf for more details about the available
odfWeave uses the noweb convention for R code. In-line R commands
should be in
Sexpr calls. The
Sexpr text should all be
completely in one visual format.
e.g., changing the color of part of the
Sexpr could result in an error. Block code chunks should use the
<<>>= syntax (i.e. no Latex syntax will currently work).
The image format and sizes are specified using
The dimensions of the image file and the dimensions of the rendered
image can be set independently. See
setImageDefs for more
The document formatting.odt in the package's examples directory illustrates the process of changing the appearance of the various document elements.
an ODF file with the R output
1 2 3 4 5 6 7 8 9 10 11 12 13 14
## Not run: vignette("odfWeave") ## Not run: demoFile <- system.file("examples", "examples.odt", package = "odfWeave") demoFile <- system.file("examples", "testCases.odt", package ="odfWeave") demoFile <- system.file("examples", "formatting.odt", package = "odfWeave") ## End(Not run) demoFile <- system.file("examples", "simple.odt", package = "odfWeave") outputFile <- gsub("simple.odt", "output.odt", demoFile) library(odfWeave) odfWeave(demoFile, outputFile)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.