save_df()
saves a dataframe in the specified format (csv, tsv, rda, or xlsx) in a
specified directory. If the directory does not exist, it will be created.
The recommended file type is RDA.
Usage
save_df(
df,
file_name,
dir_name,
date = FALSE,
file_type = c("csv", "tsv", "rda", "xlsx")
)
Arguments
- df
The dataframe to save.
- file_name
The name of the file to save.
- dir_name
The directory where the file will be saved.
- date
If TRUE, a directory with the current date as name will be created in the directory with
dir_name
.- file_type
The type of file to save the dataframe as. Options are "csv", "tsv", "rda", or "xlsx".
Examples
# Save a metadata dataframe as an RDA file
save_df(example_metadata, "metadata", "my_data", file_type = "rda")
file.exists("my_data/metadata.rda") # Check if the file exists
#> [1] TRUE
unlink("my_data", recursive = TRUE) # Clean up the created directory