ugatsdb-package {ugatsdb} | R Documentation |
Uganda Time Series Database API
Description
An R API providing easy access to a relational database with macroeconomic, financial and development related time series data for Uganda. Overall more than 5000 series at varying frequency (daily, monthly, quarterly, annual in fiscal or calendar years) can be accessed through the API. The data is provided by the Bank of Uganda, the Ugandan Ministry of Finance, Planning and Economic Development, the IMF and the World Bank. The database is being updated once a month.
Functions
Functions to retrieve tables identifying the data
datasources()
datasets()
series()
Function to retrieve the data from the database
Functions to reshape data and add temporal identifiers
long2wide()
wide2long()
expand_date()
Function to export wide format data to Excel
Helper functions (useful esp. for common Excel formats)
Global Macros with core ID variables in the database
Function to renew database connection without reloading the package
Examples
library(ugatsdb)
library(magrittr) # Pipe %>% operators
library(xts) # Time series class and pretty plots
# Plotting daily IFEM Buying and Selling Rates from the Bank of Uganda
get_data("BOU_E", c("E_IFEM_B", "E_IFEM_S"), from = 2020) %>%
as.xts %>% plot
library(dygraphs)
# Same generating a dynamic chart
get_data("BOU_E", c("E_IFEM_B", "E_IFEM_S"), from = 2020) %>%
as.xts %>% dygraph
# Static plot but with legend showing variable labels
get_data("BOU_E", c("E_IFEM_B", "E_IFEM_S"), from = 2020, wide = FALSE) %>%
long2wide(names_from = "Label") %>% as.xts %>%
plot(legend.loc = "topleft")