Generalized data input-output functionality with specifics for common files. write_data saves inputted data out to a data file if requested and returns it to the console, invisible-ly. Currently available for yaml, csv, and json file extensions. read_data reads in a specified data file. Specific functions available include read_rodents, read_rodents_dataset, read_covariates, read_climate_forecasts, read_newmoons, and read_metadata.
Usage
write_data(
x = NULL,
main = ".",
subdirectory = "data",
save = TRUE,
overwrite = TRUE,
filename = NULL,
quiet = FALSE
)
read_data(
main = ".",
data_name = NULL,
dataset = "all",
datasets = prefab_datasets()
)
read_rodents_dataset(main = ".", dataset = "all")
read_rodents(main = ".", datasets = prefab_datasets())
read_newmoons(main = ".")
read_covariates(main = ".")
read_metadata(main = ".")
read_climate_forecasts(main = ".")Arguments
- x
Data, such as a
data.frameorlist, to be written out.- main
charactervalue of the name of the main component of the directory tree.- subdirectory
charactervalue defining the data subdirectory of the portalcasting directory tree.- save
logicalindicator controlling ifxshould be saved out.- overwrite
logicalindicator of whether or not file writing should occur even if a local copy already exists.- filename
charactername of the file for savingx.- quiet
logicalindicator if messages should be quieted.- data_name
characterrepresentation of the data needed. Current options include"rodents","rodents_table","covariates","climate_forecasts","newmoons", and"metadata".- dataset, datasets
characterof the grouping name(s) used to define the rodents. Standard options are"all","controls", and"exclosures".datasetcan only be length 1,datasetsis not restricted in length.
Value
write_data: x as input, invisible-ly. read_data: data requested, typically as a data.frame or list.
See also
File read-write functions:
directory configuration file
Examples
if (FALSE) { # \dontrun{
main1 <- file.path(tempdir(), "io")
setup_dir(main = main1)
write_data(main = main1,
x = data.frame(rnorm(10)),
filename = "xx.csv")
read_data(main = main1)
read_rodents(main = main1)
read_rodents_dataset(main = main1)
read_covariates(main = main1)
read_climate_forecasts(main = main1)
read_newmoons(main = main1)
read_metadata(main = main1)
unlink(main1, force = TRUE, recursive = TRUE)
} # }