make_flag | R Documentation |
Make a list of functions used flags
make_flag(set_value, flags = c(TRUE, FALSE))
set_value |
logical value used to set what is returned |
flags |
vector of possible values for a flag |
A list of two functions: 'set' and 'value'. The function 'set' takes a logical variable of length 1 that is used to set the logical value returned by 'value'. The function 'value' does not take an argument and returns either the default value provided when the function was created or the last value provided to the 'set' function.
# Create function list with `value` defaulted to TRUE
tf_flag <- make_flag(TRUE, c(TRUE, FALSE))
tf_flag$value()
# reset `value`
tf_flag$set(FALSE)
tf_flag$value()
# Create function list with `value` defaulted to FALSE
tf_flag <-make_flag(TRUE, c(TRUE, FALSE))
tf_flag$value()
# reset `value`
tf_flag$set(TRUE)
tf_flag$value()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.