readr (version 2.1.5)

read_rds: Read/write RDS files.

Description

Consistent wrapper around saveRDS() and readRDS(). write_rds() does not compress by default as space is generally cheaper than time.

Usage

read_rds(file, refhook = NULL)

write_rds( x, file, compress = c("none", "gz", "bz2", "xz"), version = 2, refhook = NULL, text = FALSE, path = deprecated(), ... )

Value

write_rds() returns x, invisibly.

Arguments

file

The file path to read from/write to.

refhook

A function to handle reference objects.

x

R object to write to serialise.

compress

Compression method to use: "none", "gz" ,"bz", or "xz".

version

Serialization format version to be used. The default value is 2 as it's compatible for R versions prior to 3.5.0. See base::saveRDS() for more details.

text

If TRUE a text representation is used, otherwise a binary representation is used.

path

[Deprecated] Use the file argument instead.

...

Additional arguments to connection function. For example, control the space-time trade-off of different compression methods with compression. See connections() for more details.

Examples

Run this code
temp <- tempfile()
write_rds(mtcars, temp)
read_rds(temp)
if (FALSE) {
write_rds(mtcars, "compressed_mtc.rds", "xz", compression = 9L)
}

Run the code above in your browser using DataLab