knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "README-", error = TRUE )
The goal of tgconfig is to provide infrastructure for managing package parameters, inspired by pgkconfig
code can be found at https://github.com/tanaylab/tgconfig
install.packages('tgconfig', repos=c(getOption('repos'), 'https://tanaylab.github.io/repo'))
Parameters are easy to get in relevant functions within a package:
library(tgconfig) register_param('param', 'scrdb') set_param('param', 'value', 'scrdb') get_param_strict('param', 'scrdb')
Error is thrown if a parameter is missing:
get_param_strict('another', 'scrdb')
Developers are able to register parameters and set their default value in a config file that is part of the package in YAML format:
char_param: value expr_param: !expr seq(1:5) numeric_param: 500 boolean_param: true
config_file <- example_config_file() register_params(config_file, 'scrdb') get_package_params('scrdb')
Users are able to override parameters using their own YAML:
char_param: 'user_char' expr_param: 'user_exp' numeric_param: 700 boolean_param: false
override_params(system.file('config/override_example.yaml', package='tgconfig'), package='scrdb') get_package_params('scrdb')
Users get an exception when trying to override a parameter that was not registered:
set_param('other_param', 'value', 'scrdb')
Users can load multiple parameters to the current environment:
load_params_to_env(c('expr_param', 'boolean_param'), 'scrdb') expr_param boolean_param
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.