| code {SRPM} | R Documentation |
List available code chunks, figures, and cache databases and retrieve them
code(name = NULL) figure(name) cache(name) runcode(namevec, env = parent.frame(), useCache = TRUE) loadcache(namevec, env = parent.frame()) article() edit(name, ...) ## S4 method for signature 'codeObject': edit(name, ...)
name |
the name of a code chunk/figure/cache database (character) or its sequence number |
namevec |
a vector of names of code chunks, or an object of class
"codeObject" |
env |
environment in which to eevaluate code or load a cache database |
useCache |
logical, indicating whether a cache database should be used if available |
... |
other arguments passed to methods |
When code is called without arguments, the list of available
objects is printed. Otherwise, the corresponding object is returned
by the function.
figure views a figure associated with a code chunk (if there is
one). Currently, this just loads the figure in the PDF viewer. In
particular, the code which produced the figure is not run.
cache returns the database object associated with a code chunk
if a cache database exists for that chunk.
runcode takes a code chunk name or a sequence of code chunk
names and evaluates the code associated with that code chunk. If a
code chunk has a cache database associated with it, then the code for
that code chunk is not run and the objects from the cache
database are lazy-loaded instead. If namevec is an object of
class "codeObject", then runcode executes the code in
that object.
article simply loads the article text in its finished form
(currently, just a PDF file).
edit allows the user to edit the code associated with a code
chunk in an external editor. Once editing is finished, edit
returns a modified "codeObject" object.
code and figure both return an object of class
"codeObject". cache returns an object inheriting from
class "filehash". edit returns an object of class
"codeObject".
Roger D. Peng rpeng@jhsph.edu
pkg <- system.file("SRP-ex", "srp_simple", package = "SRPM")
setPackage(pkg)
## Show annotated list of code chunks
code()
## Load cache from code chunk 2
loadcache(2)
ls()
## Make table from code chunk 3
runcode(3)
## Show Figure 1
## Not run:
figure(1)
## End(Not run)