load_cfg {restatapi} | R Documentation |
Load configuration data from JSON
Description
Load the configuration information to the '.restatapi_env' from the JSON configuration file.
Usage
load_cfg(
api_version = "default",
cfg_file = "github",
load_toc = FALSE,
parallel = TRUE,
max_cores = FALSE,
verbose = FALSE
)
Arguments
api_version |
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. |
cfg_file |
The location of the config file. It can be either "github" (the default value) or "local". |
load_toc |
The default value |
parallel |
A boolean with the default value |
max_cores |
A boolean with the default value |
verbose |
A boolean if the verbose message about the configuration to be showed or not. The default is |
Details
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
Value
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 theapi_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 withoptions(restatapi_dmethod=...)
Examples
load_cfg(parallel=FALSE)
options(restatapi_dmethod="auto")
load_cfg(api_version="test",verbose=TRUE,max_cores=FALSE)
load_cfg()
eu<-get("cc",envir=.restatapi_env)
eu$EU28
eu$EA15