tc <- function(l) Filter(Negate(is.null), l)
tcnull <- function(x) if (all(sapply(x, is.null))) NULL else x
pluck <- function(x, name, type) {
if (missing(type)) {
lapply(x, "[[", name)
} else {
vapply(x, "[[", name, FUN.VALUE = type)
}
}
assert <- function(x, y) {
if (!is.null(x)) {
if (!inherits(x, y)) {
stop(deparse(substitute(x)), " must be of class ",
paste0(y, collapse = ", "), call. = FALSE)
}
}
}
dt2df <- function(x, idcol = TRUE) {
(data.table::setDF(
data.table::rbindlist(x, use.names = TRUE, fill = TRUE, idcol = idcol)))
}
`%||%` <- function (x, y) if (is.null(x) || length(x) == 0) y else x
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.