knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
library(utilitarian)

usePackage

Don't know if something is installed? Want your code to install packages when run if they're absent? usePackage is here to help!

usePackage("dichromat")

Combine usePackage() with the purrr package to attempt to attach and (install if unavailable) multiple packages. Walk doesn't return an output, only the secondary effects. In this case, an attached package from each of those in the character vector.

purrr::walk(c("DT", "dplyr", "lubridate", "readr", "ggplot2", "ggridges", "viridis", "hrbrthemes", "forcats", "tidyr"), ~ usePackage(.x))

libraries

Tired of quoting and typing in multiple library statements? No more!

Several flavours:

Silent and easy typing

Don't bother with quotes. Just type your package names in and off you go.

libraries(dichromat, jsonlite)
sessionInfo()

Quoted

Like library() but better.

libraries("dichromat", "jsonlite", quoted = T)
sessionInfo()

Quoted in a Character Vector

Like library() but even better.

mypkgs <- c("dichromat", "jsonlite")
libraries(mypkgs, quoted = T)
sessionInfo()

Unquote or Quoted but with Verbose Feedback

Because you like R to talk back.

libraries(dichromat, verbose = TRUE)


TheZetner/utilitarian documentation built on Aug. 13, 2022, 12:31 p.m.