Last active
April 7, 2020 14:27
-
-
Save oganm/a401ef9eaeec3ac82ea733fdfcfb9831 to your computer and use it in GitHub Desktop.
install arbitrary packages from command line
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
#!/usr/bin/Rscript | |
# Rscript install.R packageName | |
# point of this is to be able to install arbitrary packages from CRAN, github, bioconductor, etc from command line | |
# used for my remote server where I use the root library to share packages between my user and the shiny user | |
# sudo install.R glue oganm/ogbox bioc::3.6/affy | |
library(dplyr) | |
library(ogbox) | |
print(.libPaths()) | |
userID = Sys.getenv('USER') | |
# print(userID) | |
if(userID == 'root'){ | |
print('Installing to root library') | |
lib = "/usr/local/lib/R/site-library" | |
} else{ | |
print('Installing to user library') | |
lib = .libPaths()[1] | |
} | |
args <- commandArgs(trailingOnly = TRUE) | |
args %>% sapply(function(x){ | |
ogbox::generic_install(x,lib = lib) | |
}) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment