Skip to content
Prev 76466 / 398502 Next

Advice about system for installing & updating all R packa ge in a Linux Lab?

If you have several different versions of R installed, you might want to use
a script like this one, which should work on (at least) 1.9.1 and newer.

<script>
#!/bin/sh

echo "##############"
echo "## This script will attempt to install all available R packages"
echo "## from the package repositories:"
echo "##"
echo "##   - CRAN:  http://cran.r-project.org/"
echo "##   - BioCondictor:  http://www.bioconductor.org"
echo "##"
echo "## As well as Pfizer custom packages"
echo "## "
echo "##   - Rlsf:  ~warneg/src/R/Rlsf"
echo "##   - AffyTool: nlvfs016:rstat-data/"
echo "##               ExpressionAnalysis/StandardAffyAnalysis/AffyTool"
echo "##"
echo "##############"
echo "##"

if [ -z '$1' ]; then
  RCMD="R"
  echo "## Parameter 1 : R Command Name = $RCMD (Default)"
else
  RCMD=$1
  echo "## Parameter 1 : R Command Name = $RCMD"
fi
export RCMD
echo $RCMD

echo "##"
echo "##############"
echo "##"
echo "## Starting R ..."
echo "##"

$RCMD --vanilla <<EOF

##
## Update installed packages
##
update.packages (repos ="http://cran.r-project.org",ask = FALSE,
installWithVers=TRUE )

##
## Install New Packages from CRAN
##
#
if (exists("new.packages",mode="function"))
   {
     options(repos="http://cran.r-project.org")
     new.list <- new.packages(ask=FALSE)
   } else
   {
     CRAN.list <- CRAN.packages()[,1]
     here.list <- installed.packages()[,1]
     new.list <- CRAN.list[ ! CRAN.list  %in% here.list ]
     
   }
   install.packages(pkgs=new.list, dependencies=TRUE, installWithVers=TRUE )

##
## Install (New) Bioconductor Packages
##
source("http://www.bioconductor.org/getBioC.R") 
getBioC(groupName="all")
y

EOF

echo "##############"
echo "## All Done!"
echo "##"
echo "## *Check the log for failed package installs*"
echo "##"
echo "##############"
</script>
LEGAL NOTICE\ Unless expressly stated otherwise, this messag...{{dropped}}