R/export_rds.R

Defines functions export_rds

Documented in export_rds

#' @title Export data-frames as rds files
#'
#' @description
#' Export data-frames as rds files.
#'
#' @usage
#' export_rds(x, dirname, rpath)
#'
#' @param x A data-frame.
#' @param dirname A directory above 1) the rds file and 2) the R file.
#' @param rpath Relative to \code{dirname}, path to the rds file.
#'
#' @seealso
#' \code{\link{import_rds}}
#'
#' @importFrom readr write_rds
#'
#' @export

export_rds <- function(x,
                       dirname,
                       rpath) {

  path <- zhaoy::path(basename = dirname,
                      rpath)

  readr::write_rds(x = x,
                   file = path,
                   compress = "gz")

}
zhaoy/zhaoy documentation built on Feb. 1, 2024, 7:50 p.m.