Skip to content

Commit 329567c

Browse files
committed
Add script for installing R packages
1 parent cfbfd8b commit 329567c

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

tools/scripts/install_r_pkgs.R

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env Rscript
2+
#
3+
# Installs R packages.
4+
#
5+
# The script is called with one or more arguments, where each argument is a
6+
# package name to install.
7+
8+
# Get only the trailing command-line arguments:
9+
args <- commandArgs( trailingOnly = TRUE );
10+
11+
# Check that at least one package name has been provided...
12+
n <- length( args );
13+
if ( n == 0 ) {
14+
stop( "Must provide at least one package to install.", call. = FALSE );
15+
}
16+
# Install each package...
17+
for ( i in 1:n ) {
18+
install.packages( args[ i ], repos = "http://lib.stat.cmu.edu/R/CRAN/" );
19+
}

0 commit comments

Comments
 (0)