get_param | R Documentation |
This is a function factory to create functions which output the value of a configuration parameter.
get_param(..., if_null = NULL)
... |
Character string(s) giving a(the) field(s) in a configuration file. |
if_null |
A value to fill an unset parameter, or the function |
A function.
FINANCIAL.TIMESTAMP
Other functions to get specific 2dii configuration parameters:
FINANCIAL.TIMESTAMP()
# get_param() is a function factory # Create a `get_a_value()` function get_a_value <- get_param("a_field") class(get_a_value) # Create an example configuration file config <- glue::glue(" default: a_field: a_value ") show_config(config) # Write the config file to a temporary file path_to_config_file <- tempfile() readr::write_lines(config, path_to_config_file) # Use `get_a_value()` to get a value from a field in the example config file get_a_value(file = path_to_config_file) # Fails: The parameter 'bad' doesn't exist, so it is `NULL` fails <- get_param("bad", if_null = stop) try(fails()) returns_null <- get_param("bad") returns_null() returns_value_passed_to_if_null <- get_param("bad", if_null = 1) returns_value_passed_to_if_null()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.