#' Show slot information
#'
#' @export
#' @note Updated 2023-09-21.
#'
#' @details
#' Standardized to Bioconductor `show()` method conventions.
#' Refer to `SummarizedExperiment` method for example.
#'
#' @param list `list`.
#' Named list containing slot metadata.
#'
#' @return Console output, via [cat()].
#'
#' @examples
#' showSlotInfo(list(
#' dir = "~",
#' skip = NULL,
#' filtered = TRUE
#' ))
showSlotInfo <- function(list) {
assert(is.list(list))
list <- Filter(f = Negate(is.null), x = list)
list <- Filter(f = hasLength, x = list)
out <- unlist(Map(
f = function(name, x) {
if (length(x) == 1L) {
paste0(name, ": ", x)
} else {
if (hasNames(x) && length(x) <= 4L) {
prefix <- paste0("[", names(x), "]")
info <- paste(prefix, x, sep = " ", collapse = "; ")
} else {
info <- headtail(x)
}
paste0(name, "(", length(x), "): ", info)
}
},
name = names(list),
x = list,
USE.NAMES = FALSE
))
cat(out, sep = "\n")
invisible(NULL)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.