#

R – Packages

Step 0: To use R on the Odyssey cluster, load the appropriate version available via our module system. See the modules list for available versions.

When loading R from the Lmod system, 100s of common packages have already been installed. The list is available here. However, if you need to install new packages locally, the process is fairly straight-forward.
See also: R - Basics

Prerequisite: Create a directory for your R package installs

Before attempting to install your own R packages, you will first need to create a directory for your local R package installs to live in. You'll only need to do this once for each version of R you use. This is the path you will then point the R_LIBS_USER variable to.

mkdir -pv ~/apps/R_version

It's highly recommended that you "tag" your package folder with the specific version of R you are using to install them, so that you don't risk in future to forget and accidentally  use the packages you are installing with a different version of R.

Prerequisite: Understanding the R_LIBS_USER environment variable

The R_LIBS_USER environment variable is used by R to determine where packages you install should be located when the install.packages() function is called and when you later use them. It is set using:

export R_LIBS_USER=$HOME/apps/R_version:$R_LIBS_USER

Note: You can also add this to you .bashrc if you wish, but we recommend calling this directly after loading the module in your scripts or when running R interactively. This ensures that your local library is the first one checked by R for installs and libraries..

Installing Packages and Running R

To install packages, you'll need to load an R module, set your R_LIBS_USER variable, and run R. We recommend choosing a specific R module rather than simply using "module load R". Look up available R modules here: https://portal.rc.fas.harvard.edu/apps/modules/R

Example:
module load R/3.5.1-fasrc01
export R_LIBS_USER=$HOME/apps/R_3.5.1:$R_LIBS_USER
R

Now when you use R's install.packages() function, the package will be installed in the specified directory.

Examples:
install.packages("ape") (You will be asked to pick a mirror site to download from)
install.packages("ape", repos="http://cran.r-project.org") (You can also specify a mirror)

 

[user@rclogin ~]$ srun -p test --pty -t 60 -n1 --mem 4000  /bin/bash 
[user@computenode ~]$ module load R/3.5.1-fasrc01  
[user@computenode ~]$ mkdir -pv ~/apps/R_3.5.1
mkdir: created directory ‘/n/home00/user/apps’
mkdir: created directory ‘/n/home00/user/apps/R_3.5.1’

[user@computenode ~]$ export R_LIBS_USER=$HOME/apps/R_3.5.1:$R_LIBS_USER
[user@computenode ~]$ R --quiet
> install.packages('ape',repos="http://cran.r-project.org")
Installing package into ‘/n/home00/user/apps/R_3.5.1’
trying URL 'http://cran.r-project.org/src/contrib/ape_5.2.tar.gz'
Content type 'application/x-gzip' length 790069 bytes (771 KB)
==================================================downloaded 771 KB
* installing *source* package ‘ape’ ...
.... omitted output ..... 
** testing if installed package can be loaded
* DONE (ape)

 

Packages in R

> installed.packages()
...
Version Priority
ADGofTest "0.3" NA
AnDE "1.0" NA
BB "2014.1-1" NA
Brobdingnag "1.2-4" NA
CpGassoc "2.11" NA
DBI "0.2-7" NA
DEoptimR "1.0-1" NA
Defaults "1.1-1" NA
FNN "1.1" NA
Formula "1.1-1" NA
GSA "1.03" NA
GWAF "2.1" NA
GenABEL "1.8-0" NA
GenABEL.data "1.0.0" NA
Hmisc "3.14-4" NA
MCMCpack "1.3-3" NA
MatchIt "2.4-21" NA
MetaSKAT "0.40" NA
NLP "0.1-3" NA
R.methodsS3 "1.6.1" NA
R2WinBUGS "2.1-19" NA
RColorBrewer "1.0-5" NA
RCurl "1.95-4.1" NA
RJSONIO "1.2-0.2" NA
RSQLite "0.11.4" NA
RSQLite.extfuns "0.0.1" NA
RSiena "1.1-232" NA
Rcmdr "2.0-4" NA
Rcpp "0.11.2" NA
RcppArmadillo "0.4.300.8.0" NA
RcppEigen "0.3.2.1.2" NA
Rserve "1.7-3" NA
SKAT "0.95" NA
SnowballC "0.5" NA
SparseM "1.03" NA
TH.data "1.0-3" NA
TTR "0.22-0" NA
XML "3.98-1.1" NA
abind "1.4-0" NA
akima "0.5-11" NA
amap "0.8-12" NA
aod "1.3" NA
ape "3.1-2" NA
aplpack "1.2.9" NA
arm "1.7-03" NA
base64 "1.1" NA
bdsmatrix "1.3-1" NA
beanplot "1.1" NA
bitops "1.0-6" NA
caTools "1.17" NA
car "2.0-20" NA
chron "2.3-45" NA
coda "0.16-1" NA
colorspace "1.2-4" NA
corpcor "1.6.6" NA
coxme "2.2-3" "optional"
cubature "1.1-2" NA
data.table "1.9.2" NA
deSolve "1.10-9" NA
devtools "1.5" NA
dichromat "2.0-0" NA
digest "0.6.4" NA
discretization "1.0-1" NA
doParallel "1.0.8" NA
doRNG "1.6" NA
doSNOW "1.0.12" NA
dynamicTreeCut "1.62" NA
e1071 "1.6-3" NA
effects "3.0-0" NA
evaluate "0.5.5" NA
expm "0.99-1.1" NA
fBasics "3010.86" NA
fastICA "1.2-0" NA
fastcluster "1.1.13" NA
fastmatch "1.0-4" NA
fields "7.1" NA
flashClust "1.01-2" NA
foreach "1.4.2" NA
forecast "5.4" NA
formatR "0.10" NA
formula.tools "1.3.4" NA
fracdiff "1.4-2" NA
functional "0.4" NA
gdata "2.13.3" NA
geepack "1.1-6" NA
ggplot2 "1.0.0" NA
glmnet "1.9-8" NA
gplots "2.14.1" NA
gridExtra "0.9.1" NA
grplasso "0.4-3" NA
gss "2.1-2" NA
gsubfn "0.6-5" NA
gtable "0.1.2" NA
gtools "3.4.1" NA
highr "0.3" NA
httr "0.3" NA
hwriter "1.3" NA
igraph "0.7.1" NA
inline "0.3.13" NA
intervals "0.14.0" NA
iterators "1.0.7" NA
itertools "0.1-3" NA
kernlab "0.9-19" NA
knitr "1.6" NA
labeling "0.2" NA
lasso2 "1.2-19" NA
latticeExtra "0.6-26" NA
lda "1.3.2" NA
leaps "2.9" NA
lhs "0.10" NA
lme4 "1.1-6" NA
lmtest "0.9-33" NA
locfit "1.5-9.1" NA
maps "2.3-7" NA
maptools "0.8-30" NA
markdown "0.7" NA
matrixStats "0.10.0" NA
matrixcalc "1.0-3" NA
mclust "4.3" NA
memoise "0.2.1" NA
meta "3.6-0" NA
mi "0.09-18.03" NA
mime "0.1.1" NA
minqa "1.2.3" NA
mlbench "2.1-1" NA
mlegp "3.1.4" NA
modeltools "0.2-21" NA
msm "1.3" NA
multcomp "1.3-3" NA
multicore "0.2" NA
munsell "0.4.2" NA
mvtnorm "0.9-99992" NA
nleqslv "2.2" NA
nor1mix "1.1-4" NA
numDeriv "2012.9-1" NA
operator.tools "1.3.0" NA
optmatch "0.9-1" NA
pROC "1.7.3" NA
penalized "0.9-42" NA
penalizedSVM "1.1" NA
permute "0.8-3" NA
phangorn "1.99-7" NA
pkgmaker "0.22" NA
plotrix "3.5-7" NA
plyr "1.8.1" NA
proto "0.3-10" NA
pspline "1.0-16" NA
psych "1.4.5" NA
quadprog "1.5-5" NA
quantmod "0.4-0" NA
quantreg "5.05" NA
randomForest "4.6-7" NA
raster "2.2-31" NA
registry "0.2" NA
relimp "1.0-3" NA
reshape "0.8.5" NA
reshape2 "1.4" NA
rgl "0.93.996" NA
rngtools "1.2.4" NA
robustbase "0.91-1" NA
rootSolve "1.6.5" NA
sandwich "2.3-0" NA
sas7bdat "0.5" NA
scales "0.2.4" NA
scatterplot3d "0.3-35" NA
sem "3.1-4" NA
slam "0.1-32" NA
snow "0.3-13" NA
sp "1.0-15" NA
spam "0.41-0" NA
sqldf "0.4-7.1" NA
stabledist "0.6-6" NA
statmod "1.4.20" NA
stringr "0.6.2" NA
strucchange "1.5-0" NA
subplex "1.1-4" NA
svmpath "0.953" NA
tcltk2 "1.2-10" NA
texreg "1.32" NA
tgp "2.4-9" NA
timeDate "3010.98" NA
timeSeries "3010.97" NA
tm "0.6" NA
tree "1.0-35" NA
truncnorm "1.0-7" NA
tseries "0.10-32" NA
vcd "1.3-1" NA
vegan "2.0-10" NA
whisker "0.3-2" NA
xtable "1.7-3" NA
xts "0.9-7" NA
zoo "1.7-11" NA
KernSmooth "2.23-12" "recommended"
MASS "7.3-31" "recommended"
Matrix "1.1-3" "recommended"
base "3.1.0" "base"
boot "1.3-11" "recommended"
class "7.3-10" "recommended"
cluster "1.15.2" "recommended"
codetools "0.2-8" "recommended"
compiler "3.1.0" "base"
datasets "3.1.0" "base"
foreign "0.8-61" "recommended"
grDevices "3.1.0" "base"
graphics "3.1.0" "base"
grid "3.1.0" "base"
lattice "0.20-29" "recommended"
methods "3.1.0" "base"
mgcv "1.7-29" "recommended"
nlme "3.1-117" "recommended"
nnet "7.3-8" "recommended"
parallel "3.1.0" "base"
rpart "4.1-8" "recommended"
spatial "7.3-8" "recommended"
splines "3.1.0" "base"
stats "3.1.0" "base"
stats4 "3.1.0" "base"
survival "2.37-7" "recommended"
tcltk "3.1.0" "base"
tools "3.1.0" "base"
utils "3.1.0" "base"

CC BY-NC-SA 4.0 This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. Permissions beyond the scope of this license may be available at Attribution.