Text Representations of R Objects (original) (raw)
dump {base} | R Documentation |
---|
Description
This function takes a vector of names of R objects and produces text representations of the objects on a file or connection. A dump
file can usually be [source](../../base/help/source.html)
d into anotherR session.
Usage
dump(list, file = "dumpdata.R", append = FALSE,
control = "all", envir = parent.frame(), evaluate = TRUE)
Arguments
list | character vector (or NULL). The names of R objects to be dumped. |
---|---|
file | either a character string naming a file or aconnection. "" indicates output to the console. |
append | if TRUE and file is a character string, output will be appended to file; otherwise, it will overwrite the contents of file. |
control | character vector (or NULL) indicating deparsing options. See .deparseOpts for their description. |
envir | the environment to search for objects. |
evaluate | logical. Should promises be evaluated? |
Details
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.
[source](../../base/help/source.html)
ing may not produce an identical copy ofdump
ed 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.
A dump
file can be [source](../../base/help/source.html)
d into another R (or perhaps S) session, but the functions [save](../../base/help/save.html)
and[saveRDS](../../base/help/saveRDS.html)
are designed to be used for transporting R data, and will work with R objects thatdump
does not handle. For maximal reproducibility usecontrol = "exact"
.
To produce a more readable representation of an object, usecontrol = NULL
. This will skip attributes, and will make other simplifications that make source
less likely to produce an identical copy. See [.deparseOpts](../../base/help/.deparseOpts.html)
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 [delayedAssign](../../base/help/delayedAssign.html)
, when evaluate = FALSE
might be intended.
Value
An invisible character vector containing the names of the objects which were dumped.
Note
As dump
is defined in the base namespace, the basepackage will be searched before the global environment unlessdump
is called from the top level prompt or the envir
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 of type S4
are not deparsed in a way that can besource
d. 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).
References
Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988)The New S Language. Wadsworth & Brooks/Cole.
See Also
[.deparseOpts](../../base/help/.deparseOpts.html)
for available control
settings;[dput](../../base/help/dput.html)()
, [dget](../../base/help/dget.html)()
and [deparse](../../base/help/deparse.html)()
for related functions using identical internal deparsing functionality.
[write](../../base/help/write.html)
, [write.table](../../utils/html/write.table.html)
, etc for “dumping” data to (text) files.
[save](../../base/help/save.html)
and [saveRDS](../../base/help/saveRDS.html)
for a more reliable way to save R objects.
Examples
x <- 1; y <- 1:10
fil <- tempfile(fileext=".Rdmped")
dump(ls(pattern = '^[xyz]'), fil)
print(.Last.value)
unlink(fil)
[Package _base_ version 4.6.0 Index]