Skip to content

Instantly share code, notes, and snippets.

@krlmlr
Created October 23, 2023 04:03
Show Gist options
  • Save krlmlr/46d3f4f6381fbb78e99bc19ed6f6cc90 to your computer and use it in GitHub Desktop.
Save krlmlr/46d3f4f6381fbb78e99bc19ed6f6cc90 to your computer and use it in GitHub Desktop.
Demo for rlang::check_installed()
my_fun <- function() {
rlang::local_interactive()
rlang::check_installed(c("DiagrammeR (>= 1.0.9)", "DiagrammeRsvg"))
stopifnot(requireNamespace("DiagrammeR", quietly = TRUE))
stopifnot(requireNamespace("DiagrammeRsvg", quietly = TRUE))
}
my_fun()
#> ℹ The packages "DiagrammeR" (>= 1.0.9) and "DiagrammeRsvg" are required.
#> ✖ Would you like to install them?
# Y ⏎ # user input
#> → Will install 3 packages.
#> → All 3 packages (3.91 MB) are cached.
#> + DiagrammeR 1.0.10
#> + DiagrammeRsvg 0.1
#> + htmlwidgets 1.6.2
#> ℹ No downloads are needed, 3 pkgs (3.91 MB) are cached
#> ✔ Got DiagrammeRsvg 0.1 (aarch64-apple-darwin20) (832.33 kB)
#> ✔ Got DiagrammeR 1.0.10 (aarch64-apple-darwin20) (2.28 MB)
#> ✔ Installed htmlwidgets 1.6.2 (33ms)
#> ✔ Installed DiagrammeR 1.0.10 (54ms)
#> ✔ Installed DiagrammeRsvg 0.1 (54ms)
#> ✔ 2 pkgs + 75 deps: kept 72, added 3, dld 2 (3.11 MB) [5.1s]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment