match_arg <- function(arg, assert = TRUE) {
if (is.null(arg)) return(NULL)
sys_parent <- sys.parent()
formal_args <- formals(sys.function(sys_parent))
choices <- eval(formal_args[[as.character(substitute(arg))]],
envir = sys.frame(sys_parent))
if (length(arg) > 1 || identical(arg, choices)) {
NULL
} else {
if (assert) assert_choice(arg, choices)
arg
}
}
add_class <- function(obj, class) {
set_class(obj, union(class, class(obj)))
}
unnamed <- function(...) {
x <- list(...)
if (is.null(names(x))) {
x
} else {
x[names(x) == ""]
}
}
when <- function(x, flag, value) {
assert_flag(flag)
if (flag) value else x
}
glueb <- function(..., .envir = parent.frame()) {
glue(
...,
.open = "{{",
.close = "}}",
.envir = .envir
)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.