Stage a DataFrame by saving it to a HDF5 file.

# S4 method for class 'DataFrame'
saveObject(x, path, DataFrame.character.vls = NULL, ...)

# S4 method for class 'data.frame'
saveObject(x, path, DataFrame.character.vls = NULL, ...)

Arguments

x

A DataFrame or data.frame.

path

String containing the path to a directory in which to save x.

DataFrame.character.vls

Logical scalar indicating whether to save character vectors in the custom variable length string (VLS) array format. If NULL, this is determined based on a comparison of the expected storage against a fixed length array.

...

Additional named arguments to pass to specific methods.

Value

A named list containing the metadata for x. x itself is written to a HDF5 file inside path. Additional files may also be created inside path and referenced from the metadata.

Details

This method creates a basic_columns.h5 file that contains columns for atomic vectors, factors, dates and date-times. Dates and date-times are converted to character vectors and saved as such inside the file. Factors are saved as a HDF5 group with both the codes and the levels as separate datasets.

Any non-atomic columns are saved to a other_columns subdirectory inside path via saveObject, named after its zero-based positional index within x.

If metadata or mcols are present, they are saved to the other_annotations and column_annotations subdirectories, respectively, via saveObject.

In the on-disk representation, no distinction is made between DataFrame and data.frame instances of x. Calling readDataFrame will always produce a DFrame regardless of the class of x.

Author

Aaron Lun

Examples

library(S4Vectors)
df <- DataFrame(A=1:10, B=LETTERS[1:10])

tmp <- tempfile()
saveObject(df, tmp)
list.files(tmp, recursive=TRUE)
#> [1] "OBJECT"            "_environment.json" "basic_columns.h5"