Text Representations of R Objects
This function takes a vector of names of R objects and produces
text representations of the objects on a file or connection.
dump file can usually be
sourced into another
R (or S) session.
dump(list, file = "dumpdata.R", append = FALSE, control = "all", envir = parent.frame(), evaluate = TRUE)
- character. The names of one or more R objects to be dumped.
- either a character string naming a file or a
""indicates output to the console.
fileis a character string, output will be appended to
file; otherwise, it will overwrite the contents of
- character vector indicating deparsing options.
.deparseOptsfor their description.
- the environment to search for objects.
- logical. Should promises be evaluated?
If some of the objects named do not exist (in scope), they are
omitted, with a warning. If
file is a file and no objects
exist then no file is created.
sourceing may not produce an identical copy of
dumped objects. A warning is issued if it is likely that
problems will arise, for example when dumping exotic or complex
objects (see the Note).
dump will also warn if fewer characters were written to a file
than expected, which may indicate a full or corrupt file system.
To produce a more readable representation of an object, use
control = NULL. This will skip attributes, and will make other
simplifications that make
source less likely to produce an
identical copy. See
deparse for details.
To deparse the internal representation of a function rather than
displaying the saved source, use
control = c("keepInteger",
"warnIncomplete", "keepNA"). This will lose all formatting and
comments, but may be useful in those cases where the saved source is
no longer correct.
Promises will normally only be encountered by users as a result of
lazy-loading (when the default
evaluate = TRUE is essential)
and after the use of
evaluate = FALSE might be intended.
An invisible character vector containing the names of the objects
which were dumped.
dump is defined in the base namespace, the base
package will be searched before the global environment unless
dump is called from the top level prompt or the
argument is given explicitly.
To avoid the risk of a source attribute becoming out of sync with the actual function definition, the source attribute of a function will never be dumped as an attribute.
Currently environments, external pointers, weak references and objects
S4 are not deparsed in a way that can be
sourced. In addition, language objects are deparsed in a
simple way whatever the value of
control, and this includes not
dumping their attributes (which will result in a warning).
Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) The New S Language. Wadsworth & Brooks/Cole.
x <- 1; y <- 1:10 dump(ls(pattern = '^[xyz]'), "xyz.Rdmped") print(.Last.value) unlink("xyz.Rdmped")