write_file()
is the backbone of all write_cnt()
methods, where files are written
to a connector. The function is a wrapper around write_ext()
where the appropriate
function to write the file is chosen depending on the file extension.
write_ext()
has methods defined for the following file extensions:
txt
: readr::write_lines()
csv
: readr::write_csv()
parquet
: arrow::write_parquet()
rds
: readr::write_rds()
sas7bdat
: haven::write_sas()
yml
/yaml
: yaml::write_yaml()
json
: jsonlite::write_json()
excel
: writexl::write_xlsx()
write_file(x, file, overwrite = FALSE, ...)write_ext(file, x, ...)
# S3 method for txt
write_ext(file, x, ...)
# S3 method for csv
write_ext(file, x, delim = ",", ...)
# S3 method for parquet
write_ext(file, x, ...)
# S3 method for rds
write_ext(file, x, ...)
# S3 method for xpt
write_ext(file, x, ...)
# S3 method for yml
write_ext(file, x, ...)
# S3 method for json
write_ext(file, x, ...)
# S3 method for xlsx
write_ext(file, x, ...)
write_file()
: invisible()
file.
write_ext()
: The return of the functions behind the individual methods.
Object to write
character()
Path to write the file.
logical Overwrite existing content if it exists.
Other parameters passed on the functions behind the methods for each file extension.
character()
Delimiter to use. Default is ","
.
Note that write_file()
will not overwrite existing files unless overwrite = TRUE
,
while all methods for write_ext()
will overwrite existing files by default.
# Write CSV file
temp_csv <- tempfile("iris", fileext = ".csv")
write_file(iris, temp_csv)
Run the code above in your browser using DataLab