Learn R Programming

basedosdados (version 0.2.2)

bd_write: Writes the result of operations with bdplyr() to disk

Description

Writes a remote table to disk that was called via bdplyr. It will collect the data and write to disk in the chosen format. You will only need this function if you have not yet collected the data using the bd_collect().

The comprehensive function bd_write() takes as a parameter .write_fn, which will be the name of some function (without parentheses) capable of writing a tibble to disk.

As helpers, the bd_write_rds() and bd_write_csv() functions make it easier to write in these formats, more common in everyday life, calling writing functions from {readr} package.

Usage

bd_write(
  .lazy_tbl,
  .write_fn = `?`(typed::Function()),
  path = `?`(typed::Character(length = 1)),
  overwrite = `?`(FALSE, typed::Logical(1)),
  ...
)

bd_write_rds(.lazy_tbl, path, overwrite = FALSE, compress = "none", ...)

bd_write_csv( .lazy_tbl, path = `?`(typed::Character(1)), overwrite = `?`(FALSE, typed::Logical(1)), ... )

Value

String containing the path to the created file.

Arguments

.lazy_tbl

A lazy tibble, tipically the output of bdplyr().

.write_fn

A function for writing the result of a tibble to disk. Do not use () afther the function's name, the function object should be passed. Some functions the user might consider are: writexl::write_xlsx, jsonlite::write_json, foreign::write.dta, arrow::write_feather, etc.

path

String containing the path for the file to be created. The desired folders must already exist and the file should normally end with the corresponding extension.

overwrite

FALSE by default. Indicates whether the local file should be overwritten if it already exists. Use with care.

...

Parameters passed to the .write_fn function.

compress

For bd_write_rds() only. Compression method to use: "none" (default), "gz" ,"bz", or "xz", in ascending order of compression. Remember that the higher the compression, the smaller the file size on disk, ut also the longer the time to load the data. See also: readr::write_rds().