try_eval <- function(exprs, data = NULL, warn = TRUE) {
if (!is_simple_list(data))
stop("data is not a list")
exprs <- quos_auto_name(exprs)
idx <- structure(seq_along(exprs),
names = names(exprs))
lapply(idx, function(i) {
tryCatch({
evl <- eval_tidy(exprs[[i]], data = data)
data[[names(exprs)[i]]] <<- evl
evl
}, error = function(e) {
if (warn)
warning(e[[1]])
NULL
})
})
}
try_select_vars <- function(vars, quos, warn = TRUE) {
unlist(lapply(quos, function(q) {
tryCatch({
names(select_vars(vars, !!! q))
}, error = function(e) {
if (warn)
warning(e[[1]])
NULL
})
}))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.