knitr::opts_chunk$set(echo = TRUE, comment='')
library(qoma.smuggler) library(rhli) if(!open_hli())knitr::knit_exit()
Use FAME HLI monthly frequency constant HMONTH
and FAME date literals "18m1" and "18m2" ---
abbreviations for the first and twelfth month of the year 2018.
rng <- to_fame_range(HMONTH,"18m1","18m12") rng
Convert a FAME date range rng
to a lubridate index.
tbl <- to_lubridate_index(rng) tbl
Generate some normal variates in R, add to the tibble as column 'x'.
nobs <- rng[3]-rng[2]+1 tbl['x'] <- rnorm(nobs) tbl
Setup a qoma.smuggler List
structure to hold the data.
See what it looks like with the print_catalog()
function.
mydb <- List() # mutable list entry <- newEntry( # entry with data and FAME metadata tbl$x, desc = "N(0,1)", docu = "R generated N(0,1) time series.", range = rng, obse = rhli::HOBSUM ) mydb$put('x',entry) print_catalog(mydb) mydb$get('x')
Write the contents of the qoma.smuggler List
to a FAME database.
dbfile <- file.path(tempdir(),"tmp.db") write_fame(dbfile,mydb)
Use 4GL to peek at data in FAME.
txtfile <- file.path(tempdir(),"tmp.txt") cmd <- rhli::Character(paste( "open<acc read>\"",dbfile,"\" as db;", "output<acc over>\"",txtfile,"\";", "cata db;", "whats x;", "disp x;", "output terminal;", "close db;", sep="")) rhli::cfmfame(rhli::Integer(-1), cmd) cat(readLines(txtfile), sep = '\n')
close_hli() file.remove(dbfile) file.remove(txtfile)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.