R: Read/write RDS files.

read_rds {readr} | R Documentation

## 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(path)

    write_rds(x, path, compress = c("none", "gz", "bz2", "xz"), ...)

### Arguments

`path` | Path to read from/write to.
`x` | R object to write to serialise.
`compress` | Compression method to use: "none", "gz" ,"bz", or "xz".
`...` | Additional arguments to connection function. For example, control the space-time trade-off of different compression methods with `compression`. See `connections()` for more details.

### Value

`write_rds()` returns `x`, invisibly.

### Examples

    temp <- tempfile()
    write_rds(mtcars, temp)
    read_rds(temp)

    ## Not run:
    write_rds(mtcars, "compressed_mtc.rds", "xz", compression = 9L)

    ## End(Not run)

[Package readr version 1.1.1 Index]