README.md

Rblang

R package to interface with blang CLI

The package is currently in a fairly rudimentary stage, and only supports certain functions. For the time being it allows you to run a blang model through R and return the results as an R dataframe. The functions will only work where the blang CLI command works. As such it is not possible to run models within blangSDK and blangExample. Additionally, it assumes that the project folder is within the same directory as blangSDK.

Installation

(Requires blang CLI to be setup already) 1. Install the devtools package in RStudio and load it:

install.packages("devtools")
library(devtools)
  1. Install this package using the install_github function:
install_github("UBC-Stat-ML/Rblang")

How to use the package

The package consists of three functions at the moment:

Rblang::blangModel()
Rblang::run.blangModel()
Rblang::getResult.blangModel()

More information about each function is available via the help pages. To begin, load the library and create a model. This function can take in a variety of optional arguments but the only required ones are model.name and project.path.

library(Rblang)

mod <- blangModel(project.path = ".../blangProjectName", model.name = "MyModel")

The run.blangModel function has now been modified to return another model object unique to this run. Additionally, you can choose to overwrite the default run arguments specified using blangModel to modify each run using the optional run.args parameter.

run1 <- run.blangModel(mod)

After the run is completed, the path to the results folder is stored by reading the sym-link created by blang and a list of the files in the samples folder as well as the temperatures.csv file:

 # The path to the results folder is accessed via:
run1$results.path

 # The list of files in the samples folder:
 run1$samples

 # The temperatures.csv is returned as a df via:
 temps <- run1$temps

And finally you can retrieve the results by using getResult.blangModel() and passing in the model and the name of the random variable:

y <- getResult.blangModel(run1, "y")

hist(y$value, probability = TRUE)


UBC-Stat-ML/Rblang documentation built on July 22, 2019, 9:45 a.m.