R: Save ffdf data.frames in a directory

save.ffdf {ffbase} | R Documentation

## Save ffdf data.frames in a directory

### Description

`save.ffdf` saves all ffdf data.frames in the given `dir`. Each column is stored as with filename <ffdfname>$<colname>.ff. All variables given in "..." are stored in ".RData" in the same directory. The data can be reloaded by starting a R session in the directory or by using `load.ffdf`. Note that calling `save.ffdf` multiple times for the same directory will only store the ffdf's that were given in the last call.

### Usage

    save.ffdf(
      ...,
      dir = "./ffdb",
      clone = FALSE,
      relativepath = TRUE,
      overwrite = FALSE
    )

### Arguments

`...` | `ffdf` data.frames, `ff` vectors, or other variables to be saved in the directory
`dir` | path where .RData file will be saved and all columns of supplied `ffdf`'s. It will be created if it doesn't exist.
`clone` | should the ff vectors be `clone`'d, creating a snapshot of the supplied ffdf or ff objects? This should only be necessary if you still need the ff vectors in their current storage location.
`relativepath` | `logical` if `TRUE` the stored ff vectors will have relative paths, making moving the data to another storage a simple copy operation.
`overwrite` | `logical` If `TRUE` `save.ffdf` will overwrite an previous stored `ffdf`, `.Rdata` file.

### Details

Using `save.ffdf` automagically sets the `finalizer`s of the `ff` vectors to `"close"`. This means that the data will be preserved on disk when the object is removed or the R sessions is closed. Data can be deleted either using `delete` or by removing the directory where the object were saved (`dir`).

### Note

When saving in the temporary directory pointed at by getOption("fftempdir"), `ff` assumes that the resulting files are to be deleted. Be sure to change the finalizers of the ff vectors when saving in the temporary directory.

### See Also

`load.ffdf`

### Examples

    iris.ffdf <- as.ffdf(iris)

    td <- tempfile()

    # save the ffdf into the supplied directory
    save.ffdf(iris.ffdf, dir=td)

    # what in the directory?
    dir(td)

    #remove the ffdf from memory
    rm("iris.ffdf")

    # and reload the stored ffdf
    load.ffdf(dir=td)

    tf <- paste(tempfile(), ".zip", sep="")
    packed <- pack.ffdf(file=tf, iris.ffdf)

    #remove the ffdf from memory
    rm("iris.ffdf")

    # restore the ffdf from the packed ffdf
    unpack.ffdf(tf)

[Package ffbase version 0.13.1 Index]