# print messages
msg <- function(..., startup = FALSE) {
if (startup) {
if (!isTRUE(getOption("drugverse.quiet"))) {
packageStartupMessage(text_col(...))
}
} else {
message(text_col(...))
}
}
# color messages
text_col <- function(x) {
# If RStudio not available, messages already printed in black
if (!rstudioapi::isAvailable()) {
return(x)
}
if (!rstudioapi::hasFun("getThemeInfo")) {
return(x)
}
theme <- rstudioapi::getThemeInfo()
if (isTRUE(theme$dark)) crayon::white(x) else crayon::black(x)
}
#' List all packages in the drugverse
#'
#' @param include_self Include drugverse in the list?
#' @export
#' @examples
#' drugverse_packages()
drugverse_packages <- function(include_self = TRUE) {
names <- core
if (include_self) {
names <- c(names, "drugverse")
}
names
}
# utility function
invert <- function(x) {
if (length(x) == 0) return()
stacked <- utils::stack(x)
tapply(as.character(stacked$ind), stacked$values, list)
}
# set gray color
style_grey <- function(level, ...) {
crayon::style(
paste0(...),
crayon::make_style(grDevices::grey(level), grey = TRUE)
)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.