Learn R Programming

connector (version 0.1.0)

write_file: Write files based on the extension

Description

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:

  • parquet: arrow::write_parquet()

  • excel: writexl::write_xlsx()

Usage

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, ...)

Value

write_file(): invisible() file.

write_ext(): The return of the functions behind the individual methods.

Arguments

x

Object to write

file

character() Path to write the file.

overwrite

logical Overwrite existing content if it exists.

...

Other parameters passed on the functions behind the methods for each file extension.

delim

character() Delimiter to use. Default is ",".

Details

Note that write_file() will not overwrite existing files unless overwrite = TRUE, while all methods for write_ext() will overwrite existing files by default.

Examples

Run this code
# Write CSV file
temp_csv <- tempfile("iris", fileext = ".csv")
write_file(iris, temp_csv)

Run the code above in your browser using DataLab