[ RDocumentation ](/)

Moon  [ ](https://github.com/datacamp/rdocumentation-2.0) [ Learn R
](https://www.datacamp.com/learn/r)

Search all packages and functions

[ base  (version  3.6.2  ) ](/packages/base/versions/3.6.2)

#  dump: Text Representations of R Objects

##  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 ](/link/source?package=base&version=3.6.2) ` d into
another  R  session.

##  Usage

    
    
    dump(list, file = "dumpdata.R", append = FALSE,
         control = "all", envir = parent.frame(), evaluate = TRUE)

##  Arguments

list

character vector. The names of one or more  R  objects to be dumped.

file

either a character string naming a file or a [ connection
](/link/connection?package=base&version=3.6.2) . ` "" ` 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 indicating deparsing options. See ` [ .deparseOpts
](/link/.deparseOpts?package=base&version=3.6.2) ` for their description.

envir

the environment to search for objects.

evaluate

logical. Should promises be evaluated?

##  Value

An invisible character vector containing the names of the objects which were
dumped.

##  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 ` ing may not produce an identical copy of ` dump ` 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 ](/link/source?package=base&version=3.6.2) `
d into another  R  (or perhaps S) session, but the function ` [ save
](/link/save?package=base&version=3.6.2) ` is designed to be used for
transporting  R  data, and will work with  R  objects that ` dump ` does not
handle. For maximal reproducibility use ` control = c("all", "hexNumeric") ` .

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
](/link/deparse?package=base&version=3.6.2) ` 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 ](/link/delayedAssign?package=base&version=3.6.2) ` ,
when ` evaluate = FALSE ` might be intended.

##  References

Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) _The New S Language_ .
Wadsworth & Brooks/Cole.

##  See Also

` [ dput ](/link/dput?package=base&version=3.6.2) ` , ` [ dget
](/link/dget?package=base&version=3.6.2) ` , ` [ write
](/link/write?package=base&version=3.6.2) ` . ` [ save
](/link/save?package=base&version=3.6.2) ` for a more reliable way to save  R
objects.

##  Examples

[ Run this code
](https://app.datacamp.com/workspace/preview?_tag=rdocs&rdocsPath=packages%2Fbase%2Fversions%2F3.6.2%2Ftopics%2Fdump&utm_source=r-docs&utm_medium=docs&utm_term=dump&utm_content=run_example_in_workspace)

    
    
    # NOT RUN {
    x <- 1; y <- 1:10
    fil <- tempfile(fileext=".Rdmped")
    dump(ls(pattern = '^[xyz]'), fil)
    print(.Last.value)
    unlink(fil)
    # }
    

Run the code above in your browser using  [ DataCamp Workspace
]