R/add.config.R

Defines functions add.config

Documented in add.config

#' Add project specific config to the global config
#'
#' Enables project specific configuation to be added to the global config object.  The
#' allowable format is key value pairs which are appended to the end of the \code{config}
#' object, which is accessible from the global environment.
#'
#' Once defined, the value can be accessed from any \code{ProjectTemplate2} script by
#' referencing \code{config$my_project_var}.
#'
#' @param ... A series of key-value pairs containing the configuration.  The key is the
#'            name that gets added to the config object.
#'
#
#' @return NULL
#'
#' @export
#' @examples
#' library('ProjectTemplate2')
#' \dontrun{
#' add.config(
#'     keep_bigdata=TRUE,     # Whether to keep the big data file in memory
#'     parse=7                # number of fields to parse
#' )
#'
#' if (config$keep_bigdata) ...
#' }
add.config <- function(...){
        project_config <- list(...)
        config <- get('config', envir = .TargetEnv)
        assign('config', c(config, project_config), envir = .TargetEnv)
}
connectedblue/ProjectTemplate2 documentation built on July 10, 2017, 12:03 a.m.