Created
June 22, 2022 11:56
-
-
Save kennedymwavu/142192f1016d8475ffa01143ca5d512a to your computer and use it in GitHub Desktop.
Selectively install packages. If it's already installed don't reinstall.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Just copy paste your "library" statements here using {datapasta}: | |
packages <- c( | |
"library(shiny)", "library(bs4Dash)", "library(shinyjs)", | |
"library(shinyWidgets)", "library(firebase)", "library(glue)", | |
"library(DBI)", "library(RPostgres)", "library(lubridate)", | |
"library(htmlwidgets)", "library(shinybusy)" | |
) | |
# rm "library()" leaving bare pkg chars: | |
pkg_nms <- gsub(pattern = "library\\(", replacement = "", x = packages) |> | |
gsub(pattern = "\\)", replacement = "") | |
# install the packages selectively: | |
for (package in pkg_nms) { | |
# if pkg is not installed: | |
if ( !(package %in% rownames(installed.packages())) ) { | |
install.packages(package, repos='https://cloud.r-project.org/') | |
cat('{', package, '} installed!\n', sep = '') | |
next | |
} | |
# if pkg is already installed: | |
cat('{', package, '} is already installed!\n', sep = '') | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment