1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
|
msg <- function(x, startup = FALSE) {
if (startup) {
if (!isTRUE(getOption("tidyverse.quiet"))) {
rlang::inform(x, class = "packageStartupMessage")
}
} else {
rlang::inform(x)
}
}
#' List all packages in the tidyverse
#'
#' @param include_self Include tidyverse in the list?
#' @export
#' @examples
#' tidyverse_packages()
tidyverse_packages <- function(include_self = TRUE) {
raw <- utils::packageDescription("tidyverse")$Imports
imports <- strsplit(raw, ",")[[1]]
parsed <- gsub("^\\s+|\\s+$", "", imports)
names <- vapply(strsplit(parsed, "\\s+"), "[[", 1, FUN.VALUE = character(1))
if (include_self) {
names <- c(names, "tidyverse")
}
names
}
invert <- function(x) {
if (length(x) == 0) return()
stacked <- utils::stack(x)
tapply(as.character(stacked$ind), stacked$values, list)
}
style_grey <- function(level, ...) {
crayon::style(
paste0(...),
crayon::make_style(grDevices::grey(level), grey = TRUE)
)
}
|