Save R and ff objects
ffsave
writes an external representation of R and ff objects to an ffarchive
.
The objects can be read back from the file at a later date by using the function ffload
.
ffsave(... , list = character(0L) , file = stop("'file' must be specified") , envir = parent.frame() , rootpath = NULL , add = FALSE , move = FALSE , compress = !move , compression_level = 6 , precheck=TRUE ) ffsave.image(file = stop("'file' must be specified"), safe = TRUE, ...)
... |
For |
list |
A character vector containing the names of objects to be saved. |
file |
A name for the the |
envir |
environment to search for objects to be saved. |
add |
logical indicating whether the objects shall be added to the |
move |
logical indicating whether ff files shall be moved instead of copied into the |
compress |
logical specifying whether saving to a named file is to use compression. |
compression_level |
compression level passed to |
rootpath |
optional path component that all all ff files share and that can be dropped/replaced when calling |
precheck |
logical: should the existence of the objects be checked before starting to save (and in particular before opening the file/connection)? |
safe |
logical. If |
ffsave
stores objects and ff files in an ffarchive
named <file>
:
i.e. it saves all specified objects via save
in a file named <file>.RData
and saves all ff files related to these objects in a zipfile named <file>.ffData
using an external zip
utility.
By default files are stored relative to the rootpath="\"} and will be restored relative to \code{"\"
(in its original location).
By providing a partial path prefix via argument rootpath
the files are stored relative to this rootpath
.
The rootpath
is stored in the <file>.RData
with the name .ff.rootpath
.
I.e. even if the ff objects were saved with argument rootpath
to ffsave
,
ffload
by default restores in the original location.
By using argument rootpath
to ffload
you can restore relative to a different rootpath
(and using argument rootpath
to ffsave
gave you shorter relative paths)
By using argument add
in ffsave
you can add more objects to an existing ffarchive
and by using argument list
in ffload
you can selectively restore objects.
The content of the ffarchive
can be inspected using ffinfo
before actually loading any of the objects.
The ffarchive
can be deleted from disk using ffdrop
.
a character vector with messages returned from the zip
utility (one for each ff file zipped)
The ff files are not platform-independent with regard to byte order.
For large files and the zip64 format use zip 3.0
and unzip 6.0
from http://infozip.sourceforge.net/.
Jens Oehlschlägel
## Not run: message("let's create some ff objects") n <- 8e3 a <- ff(sample(n, n, TRUE), vmode="integer", length=n, filename="d:/tmp/a.ff") b <- ff(sample(255, n, TRUE), vmode="ubyte", length=n, filename="d:/tmp/b.ff") x <- ff(sample(255, n, TRUE), vmode="ubyte", length=n, filename="d:/tmp/x.ff") y <- ff(sample(255, n, TRUE), vmode="ubyte", length=n, filename="d:/tmp/y.ff") z <- ff(sample(255, n, TRUE), vmode="ubyte", length=n, filename="d:/tmp/z.ff") df <- ffdf(x=x, y=y, z=z) rm(x,y,z) message("save all of them") ffsave.image("d:/tmp/x") str(ffinfo("d:/tmp/x")) message("save some of them with shorter relative pathnames ...") ffsave(a, b, file="d:/tmp/y", rootpath="d:/tmp") str(ffinfo("d:/tmp/y")) message("... and add others later") ffsave(df, add=TRUE, file="d:/tmp/y", rootpath="d:/tmp") str(ffinfo("d:/tmp/y")) message("... and add others later") system.time(ffsave(a, file="d:/tmp/z", move=TRUE)) ffinfo("d:/tmp/z") message("let's delete/close/remove all objects") close(a) # no file anymore, since we moved a into the ffarchive delete(b, df) rm(df, a, b, n) message("prove it") ls() message("restore all but ff files in a different directory") system.time(ffload("d:/tmp/x", rootpath="d:/tmp2")) lapply(ls(), function(i)filename(get(i))) delete(a, b, df) rm(df, a, b) ffdrop(c("d:/tmp/x", "d:/tmp/y", "d:/tmp/z")) ## End(Not run)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.