Manage cached datasets

hockeystick_cache_list()

hockeystick_cache_delete(files, force = TRUE)

hockeystick_cache_delete_all(force = TRUE)

hockeystick_cache_details(files = NULL)

hockeystick_update_all()

Arguments

files

(character) one or more complete file names

force

(logical) Should files be force deleted? Default: TRUE

Value

hockeystick_cache_list() returns a character vector of full path filenames in cache.

hockeystick_cache_delete() no return value, called for side effect.

hockeystick_cache_delete_all() no return value, called for side effect.

hockeystick_cache_details() returns list of filenames and sizes of cached files.

hockeystick_update_all() updates all datasets. No return value, called for side effect.

Details

cache_delete only accepts 1 file name, while cache_delete_all doesn't accept any names, but deletes all files. For deleting many specific files, use cache_delete in a lapply() type call

We cache using tools::R_user_dir(), find your cache folder by executing tools::R_user_dir("hockeystick","cache")

Functions

  • hockeystick_cache_list() returns a character vector of full path file names in cache

  • hockeystick_cache_delete() deletes one or more files, returns nothing

  • hockeystick_cache_delete_all() delete all files, returns nothing

  • hockeystick_cache_details() prints file name and file size of each file, supply with one or more files, or no files (and get details for all available)

  • hockeystick_update_all() updates the cache with the latest co2, temperature, sea level, and sea ice data.

References

Caching data sets: ROpenSci guide to persistent config and data for R packages: https://blog.r-hub.io/2020/03/12/user-preferences/

Examples

# \donttest{ # list files in cache hockeystick_cache_list()
#> [1] "C:\\Users\\hch\\AppData\\Local/R/cache/R/hockeystick/emissions.rds" #> [2] "C:\\Users\\hch\\AppData\\Local/R/cache/R/hockeystick/gisstemp.rds" #> [3] "C:\\Users\\hch\\AppData\\Local/R/cache/R/hockeystick/hurricanes.rds" #> [4] "C:\\Users\\hch\\AppData\\Local/R/cache/R/hockeystick/maunaloa.rds" #> [5] "C:\\Users\\hch\\AppData\\Local/R/cache/R/hockeystick/seaice.rds" #> [6] "C:\\Users\\hch\\AppData\\Local/R/cache/R/hockeystick/sealevel.rds" #> [7] "C:\\Users\\hch\\AppData\\Local/R/cache/R/hockeystick/temp2k.rds"
# List info for single files hockeystick_cache_details(files = hockeystick_cache_list()[1])
#> <hockeystick cached files> #> directory: C:\Users\hch\AppData\Local/R/cache/R/hockeystick #> #> file: C:\Users\hch\AppData\Local/R/cache/R/hockeystick/emissions.rds #> size: 1699.5 kB #> date: 2021-06-13 00:11:14 #>
hockeystick_cache_details(files = hockeystick_cache_list()[2])
#> <hockeystick cached files> #> directory: C:\Users\hch\AppData\Local/R/cache/R/hockeystick #> #> file: C:\Users\hch\AppData\Local/R/cache/R/hockeystick/gisstemp.rds #> size: 5.3 kB #> date: 2021-06-13 00:10:57 #>
# List info for all files hockeystick_cache_details()
#> <hockeystick cached files> #> directory: C:\Users\hch\AppData\Local/R/cache/R/hockeystick #> #> file: C:\Users\hch\AppData\Local/R/cache/R/hockeystick/emissions.rds #> size: 1699.5 kB #> date: 2021-06-13 00:11:14 #> #> file: C:\Users\hch\AppData\Local/R/cache/R/hockeystick/gisstemp.rds #> size: 5.3 kB #> date: 2021-06-13 00:10:57 #> #> file: C:\Users\hch\AppData\Local/R/cache/R/hockeystick/hurricanes.rds #> size: 1.6 kB #> date: 2021-06-13 00:11:12 #> #> file: C:\Users\hch\AppData\Local/R/cache/R/hockeystick/maunaloa.rds #> size: 9.5 kB #> date: 2021-06-13 00:10:56 #> #> file: C:\Users\hch\AppData\Local/R/cache/R/hockeystick/seaice.rds #> size: 0.5 kB #> date: 2021-06-13 00:10:57 #> #> file: C:\Users\hch\AppData\Local/R/cache/R/hockeystick/sealevel.rds #> size: 16.1 kB #> date: 2021-06-13 00:11:03 #> #> file: C:\Users\hch\AppData\Local/R/cache/R/hockeystick/temp2k.rds #> size: 21.8 kB #> date: 2021-06-13 00:11:12 #>
# Delete files by name in cache hockeystick_cache_delete(files = hockeystick_cache_list()[1]) # Delete all files in cache hockeystick_cache_delete_all() # Update all cached data hockeystick_update_all()
#> Warning: InternetOpenUrl failed: 'The server name or address could not be resolved'
#> Error in download.file(file_url, dl): cannot open URL 'https://data.giss.nasa.gov/gistemp/tabledata_v4/GLB.Ts+dSST.csv'
# }