Load the configuration information to the '.restatapi_env' from the JSON configuration file.
load_cfg(
api_version = "default",
cfg_file = "github",
load_toc = FALSE,
parallel = TRUE,
max_cores = FALSE,
verbose = FALSE
)
It can be either "old", "new", "test" or "current". The default value is "current" which defined by the DEFAULT_API_VERSION value of the config file.
The location of the config file. It can be either "github" (the default value) or "local".
The default value FALSE
, which means that the XML version of the Table of contents (TOC) will not be downloaded and
cached automatically in the '.restatapi_env' when the package is loaded.
A boolean with the default value TRUE
. If there are multiple cores/logical processors then part of the data
extraction is made in parallel reducing significantly the time needed for large datasets. If the value is FALSE
the option restatapi_cores
set to 1.
A boolean with the default value FALSE
. If the parameter 'parallel' is TRUE
then this parameter is taken into account otherwise it is ignored.
If the value is TRUE
, then the maximum minus one cores/logical processors are used for parallel computing. If the parameter FALSE
,
then the default value of getOption("mc.cores")
is used, if it is defined. If mc.cores
is NULL
then depending on the memory size and number of available cores/threads the restatapi_cores
are set to 2 or 4 cores/logical processors.
Otherwise the parallel processing turned off by setting the option restatapi_cores
to 1.
The number of cores used for parallel computing can be changed any time with options(restatapi_cores=...)
A boolean if the verbose message about the configuration to be showed or not. The default is FALSE
. Can be set also with options(restatapi_verbose=TRUE)
it returns 4 objects in the '.restatapi_env'
cfg
a list with all the configuration data
rav
a character string with a number defining the API_VERSION from the configuration file to be used later. It is
determined based on the api_version
parameter.
cc
a list containing the 2 character country codes of the member states for different EU composition like EU15, EU28 or EA (Euro Area).
dmethod
the download method to be used to access Eurostat database. If the 'libcurl' method exists under Windows then
it will be the default method for file download, otherwise it will be set 'auto'. The download method can be changed any time with options(restatapi_dmethod=...)
Loads configuration data from a JSON file. The function first tries to load the configuration file from GitHub.
If it is not possible it loads from the file delivered with the package. By this way different version of the API can be tested.
Since in many cases there is http/https redirection in the download which can cause problems with the 'wininet' download method, the 'libcurl' method is used when it is available.
This configuration code sets up the parallel processing to handle large XML files efficiently. By default if there is more then 4 cores/logical processors and at least 32 GB of RAM then
4 cores are used for parallel computing. If there is more then 2 cores then 2 cores are used. This default configuration can be overwritten with options(restatapi_cores=...)
or with the max_cores=TRUE
parameter.
In the second case part of the computation distributed over the maximum number minus one cores. By using the max_cores=TRUE
option there is a higher probability that the program will run out off memory for larger datasets.
In addition, the list of country codes are loaded to the variable cc
(country codes), based on the Eurostat standard code list
# \donttest{
load_cfg(parallel=FALSE)
options(restatapi_dmethod="auto")
load_cfg(api_version="test",verbose=TRUE,max_cores=FALSE)
#> restatapi: - version 0.23.2
#> - config file with the API version 3 loaded from GitHub (the 'current' API version number is 2).
#> - 2 from the 4 cores are used for parallel computing, can be changed with 'options(restatapi_cores=...)'
#> - 'auto' method will be used for file download, can be changed with 'options(restatapi_dmethod=...)'
#> - the Table of contents (TOC) was not pre-loaded into the deafult cache ('.restatapi_env').
load_cfg()
eu<-get("cc",envir=.restatapi_env)
eu$EU28
#> [1] "BE" "BG" "CZ" "DK" "DE" "EE" "IE" "EL" "ES" "FR" "HR" "IT" "CY" "LV" "LT"
#> [16] "LU" "HU" "MT" "NL" "AT" "PL" "PT" "RO" "SI" "SK" "FI" "SE" "UK"
eu$EA15
#> [1] "BE" "DE" "IE" "EL" "ES" "FR" "IT" "CY" "LU" "MT" "NL" "AT" "PT" "SI" "FI"
# }