The hardware and bandwidth for this mirror is donated by METANET, the Webhosting and Full Service-Cloud Provider.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]metanet.ch.

Caching requests from the UN Comtrade API

Caching requests from the UN Comtrade API

There is four reasons why we might want to use caching for our requests to the UN Comtrade API:

The package offers a caching option, that is fairly easy to use.

The basics of caching đŸ’Ŋ

When you set the respective argument to TRUE, a directory named comtradr will be set up in your cache directory. This is determined by the rappdirs::user_cache_dir function. It has the default values for a cache as used by cachem::cache_disk.

See here: https://cachem.r-lib.org/reference/cache_disk.html

and here: https://rappdirs.r-lib.org/reference/user_cache_dir.html

#### Now
q <- ct_get_data(reporter = "USA", 
               partner = c("DEU", "FRA", "JPN", "MEX"), 
               flow_direction = "import",
               start_date = 2020,
               end_date = 2023,
               cache = TRUE) # <----- set this argument to TRUE

If you want to modify these parameters, you need to set environment variables. You can use the usethis::edit_r_environ(scope = 'project) function to set them only for your current project.

ℹī¸ Restart your R Session after setting the environment variables! 💡

The parameters are:

See here for the details on pruning and other functions of cachem: https://cachem.r-lib.org/reference/cache_disk.html

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.