View source: R/load-predicts-data.R
| LoadPredictsData | R Documentation |
Implements a simple file-based cache. You supply a target filename (e.g. "data/predicts_2016_2022.rds"). The function will:
Look for that RDS file and the companion metadata file "filename.aux.json" (e.g. "data/predicts_2016_2022.rds.aux.json").
If both exist, verify the file hash, minimal structure, and requested years.
If validation passes return the loaded object.
Otherwise download fresh data via GetPredictsData(extract), overwrite
the RDS, write a new .aux.json, and return the dataframe.
The data are provided under a CC NC (non-commercial) license, which means that they cannot be used for commercial purposes. The 2016 release is available under a CC BY-NC-SA 4.0 license, and the 2022 release is available under a CC NC (any) license.
LoadPredictsData(file_predicts, extract = c(2016, 2022), force_refresh = FALSE)
file_predicts |
Character path to the desired PREDICTS database RDS file (must end with ".rds"). |
extract |
Integer vector of release years to fetch. Defaults to
|
force_refresh |
Logical; if TRUE always re-download and overwrite existing files. |
A dataframe containing the requested PREDICTS extract.
file_predicts <- file.path(tempdir(), "predicts.rds")
df_predicts <- LoadPredictsData(file.path(tempdir(), "predicts.rds"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.