Read and write data frames from and to a fast-storage (fst) file.
Allows for compression and (file level) random access of stored data, even for compressed datasets.
When using a
data.table object for
x, the key (if any) is preserved,
allowing storage of sorted data.
write_fst are equivalent to
write.fst (but the
former syntax is preferred).
write_fst(x, path, compress = 50, uniform_encoding = TRUE) read_fst(path, columns = NULL, from = 1, to = NULL, as.data.table = FALSE, old_format = FALSE) write.fst(x, path, compress = 50, uniform_encoding = TRUE) read.fst(path, columns = NULL, from = 1, to = NULL, as.data.table = FALSE, old_format = FALSE)
a data frame to write to disk
path to fst file
value in the range 0 to 100, indicating the amount of compression to use. Lower values mean larger file sizes.
If TRUE, all character vectors will be assumed to have elements with equal encoding.
The encoding (latin1, UTF8 or native) of the first non-NA element will used as encoding for the whole column.
This will be a correct assumption for most use cases.
Column names to read. The default is to read all all columns.
Read data starting from this row number.
Read data up until this row number. The default is to read to the last row of the stored dataset.
If TRUE, the result will be returned as a
use TRUE to read fst files generated with a fst package version lower than v0.8.0
read_fst returns a data frame with the selected columns and rows.
x (so you can use this function in a pipeline).
# Sample dataset x <- data.frame(A = 1:10000, B = sample(c(TRUE, FALSE, NA), 10000, replace = TRUE)) # Uncompressed write_fst(x, "dataset.fst") # filesize: 41 KB y <- read_fst("dataset.fst") # read uncompressed data # Compressed write_fst(x, "dataset.fst", 100) # fileSize: 4 KB y <- read_fst("dataset.fst") # read compressed data # Random access y <- read_fst("dataset.fst", "B") # read selection of columns y <- read_fst("dataset.fst", "A", 100, 200) # read selection of columns and rows