
Wrapper function for writing data functions
write_fun.RdThis function receives a file extension and returns the proper writing function.
Arguments
- extension
A string specifying the file extension that must support the returned function. Supported extensions:
'parquet','feather','dta','xlsx','csv','sas','rds'and'rdata'. This parameter is case robust.- ...
Additional arguments to be passed to the writing functions (write.csv, write.table, etc.).
Value
A function that can write data to the specified file format. The returned function will accept the data object and the file path as arguments.
Examples
if (FALSE) {
# Write data to Parquet file
writer <- write_fun("parquet")
writer(data, "file.parquet")
# Write data to CSV file with comma separator
writer <- write_fun("csv", sep = ',')
writer(data, "file.csv")
# Write data to TXT file with tab separator and specifying additional arguments
writer <- write_fun("txt", sep = '\t', col.names = FALSE)
writer(data, "file.txt")
}