Read FAME databases from R

knitr::opts_chunk$set(echo = TRUE,comment='')

FAME databases map names to data structures. FAME data types include:

The rhli package maps FAME data types to compatible basic R data types. The qoma.smuggler package constructs more complex tidyverse data structures such as Date and tibble. qoma.smuggler defines an R reference class List which implements a mutable list to hold FAME data.

The utility function open_hli() opens the FAME environment and prints diagnostic information.

library(qoma.smuggler)
library(rhli)

if(!open_hli())knitr::knit_exit()

The FAME distribution includes a number of sample databases. We will use the DRI Economics driecon sample database for this notebook.

dbname <- file.path(Sys.getenv("FAME"),"util","driecon")
cat(dbname)

The qoma.smuggler function read_fame() reads FAME data objects into a qoma.smuggler List. By default, the function read_fame() loads the entire specified database to a qoma.smuggler List.

famedata <- read_fame(dbname)

The method get_data(objectName) returns FAME data for objectName from the qoma.smuggler List. For FAME SCALAR objects, get_data(objectName) returns one value. For FAME SERIES objects, get_data(objectName) returns a tibble with multiple values.

famedata$get_data('GDP')

The method get_meta(objectName) returns FAME object meta data as a string from a qoma.smuggler List.

cat(famedata$get_meta('GDP'))

Specifying a wildcard pattern will select a subset of the data objects with a compatible pattern. You may
specify an full name, retrieving one series.

wilnam <- "ip?"
famedata <- read_fame(dbname,wilnam)

The function print_catalog() will display summary meta data for the contents retrieved. For brevity, we specify optional parameter list.len = 3 to limit output.

print_catalog(famedata,list.len = 3)

Specifying a date range will select a subset of the database with specified frequency. Here we use the FAME HLI constant HANDEC which means ANNUAL(DECEMBER) frequency. See the FAME support website CHLI documentation for available codes. Data returned will be limited to the specified date range.

range <- to_fame_range(HANDEC,"1993","2002")
famedata <- read_fame(dbname,fame_range_ = range)
print_catalog(famedata,list.len = 2)

Note the data retrieved is for the specified date range only; not an objects full date range:

famedata$get_data('GDP')

The qoma.smuggler utility function close_hli() closes the FAME environment.

close_hli()


Try the qoma.smuggler package in your browser

Any scripts or data that you put into this service are public.

qoma.smuggler documentation built on May 2, 2019, 1:15 p.m.