save_data {ecocomDP} | R Documentation |
Save a dataset
Description
Save a dataset
Usage
save_data(dataset, path, type = ".rds", name = NULL)
Arguments
dataset |
(list) One or more datasets of the structure returned by |
path |
(character) Path to the directory in which |
type |
(character) Type of file to save the |
name |
(character) An optional argument for setting the saved file name (for .rds) if you'd like it to be different than |
Value
.rds |
If |
.csv |
If |
Note
Subsequent calls won't overwrite files or directories
Examples
# Create directory for the data
mypath <- paste0(tempdir(), "/data")
dir.create(mypath)
# Save as .rds
save_data(ants_L1, mypath)
dir(mypath)
# Save as .rds with the name "mydata"
save_data(ants_L1, mypath, name = "mydata")
dir(mypath)
# Save as .csv
save_data(ants_L1, mypath, type = ".csv")
dir(mypath)
## Not run:
# Save multiple datasets
ids <- c("edi.193.5", "edi.303.2", "edi.290.2")
datasets <- lapply(ids, read_data)
save_data(datasets, mypath)
dir(mypath)
## End(Not run)
# Clean up
unlink(mypath, recursive = TRUE)