| Line 39... |
Line 39... |
| 39 |
and \code{\link{load}}, which save and restore one or more named
|
39 |
and \code{\link{load}}, which save and restore one or more named
|
| 40 |
objects into an environment. They are widely used by \R itself, for
|
40 |
objects into an environment. They are widely used by \R itself, for
|
| 41 |
example to store metadata for a package and to store the
|
41 |
example to store metadata for a package and to store the
|
| 42 |
\code{\link{help.search}} databases: the \code{".rds"} file extension
|
42 |
\code{\link{help.search}} databases: the \code{".rds"} file extension
|
| 43 |
is most often used.
|
43 |
is most often used.
|
| 44 |
|
44 |
|
| 45 |
Functions \code{\link{serialize}} and \code{\link{unserialize}}
|
45 |
Functions \code{\link{serialize}} and \code{\link{unserialize}}
|
| 46 |
provide a slightly lower-level interface to serialization: objects
|
46 |
provide a slightly lower-level interface to serialization: objects
|
| 47 |
serialized to a connection by \code{serialize} can be read back by
|
47 |
serialized to a connection by \code{serialize} can be read back by
|
| 48 |
\code{readRDS} and conversely.
|
48 |
\code{readRDS} and conversely.
|
| 49 |
|
49 |
|
| 50 |
All of these interfaces use the same serialization format, which has
|
50 |
All of these interfaces use the same serialization format, which has
|
| 51 |
been used since \R 1.4.0 (but extended from time to time as new
|
51 |
been used since \R 1.4.0 (but extended from time to time as new
|
| 52 |
object types have been added to \R). However, \code{save} writes a
|
52 |
object types have been added to \R). However, \code{save} writes a
|
| 53 |
single line header (typically \code{"RDXs\n"}) before the
|
53 |
single line header (typically \code{"RDXs\n"}) before the
|
| 54 |
serialization of a single object (a pairlist of all the objects to be
|
54 |
serialization of a single object (a pairlist of all the objects to be
|
| 55 |
saved).
|
55 |
saved).
|
| 56 |
|
56 |
|
| 57 |
Compression is handled by the connection opened when \code{file} is a
|
57 |
Compression is handled by the connection opened when \code{file} is a
|
| 58 |
file name, so is only possible when \code{file} is a connection if
|
58 |
file name, so is only possible when \code{file} is a connection if
|
| 59 |
handled by the connection. So e.g. \code{\link{url}} connections will
|
59 |
handled by the connection. So e.g. \code{\link{url}} connections will
|
| 60 |
needed to be wrapped in a call to \code{\link{gzcon}}.
|
60 |
needed to be wrapped in a call to \code{\link{gzcon}}.
|
| 61 |
|
61 |
|
| 62 |
If a connection is supplied it will be opened (in binary mode) for the
|
62 |
If a connection is supplied it will be opened (in binary mode) for the
|
| 63 |
duration of the function if not already open: if it is already open it
|
63 |
duration of the function if not already open: if it is already open it
|
| 64 |
must be in binary mode for \code{saveRDS(ascii = FALSE)} (the
|
64 |
must be in binary mode for \code{saveRDS(ascii = FALSE)} (the
|
| 65 |
default).
|
65 |
default).
|
| 66 |
}
|
66 |
}
|