Last active
September 28, 2023 12:12
-
-
Save StaffanBetner/d632bd70686aebd8e488bdc1a454c8e2 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
if(!("pak" %in% as.data.frame(installed.packages())$Package)){install.packages("pak")} | |
require(pak) | |
pkg_load <- function(...) { | |
if(!("pak" %in% as.data.frame(installed.packages())$Package)){install.packages("pak")} | |
pack <- sapply(match.call(), as.character)[-1] | |
pack[!(pack %in% as.data.frame(installed.packages())$Package)] -> to_install | |
if(length(to_install) > 0) pak(to_install) else "" | |
lapply(X = pack, FUN = function(x){tryCatch(require(x, character.only = T), error = function(e){NULL})}) -> X | |
} | |
pkg_update <- function(...){pkg_install(rownames(old.packages(checkBuilt = TRUE)), upgrade = TRUE, ask = FALSE)} | |
#if (interactive() && getRversion() >= "4.0.0") { | |
# globalCallingHandlers( | |
# packageNotFoundError = function(err) { | |
# try(pak::handle_package_not_found(err)) | |
# } | |
# ) | |
#} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment