From WPKG | Open Source Software Deployment and Distribution
Jump to: navigation, search

This is a silent installer and uninstalled for R, a statistical programming language. Each version of R can be installed in parallel, however for cleanliness we don't want that, and so uninstall older versions. The components are listed in JRins.pl however they've been reorganised in trunk which will become 2.10, more details are in theCHANGES file, under INSTALLATION.

This install works independed of the R version and installes always the newest R version. The "revision" has to be increased from time to time to trigger the upgrade of the package.

 <package id="r" name="R" revision="1" priority="0" reboot="false">
      <check type="uninstall" condition="exists" path="R for Windows.*" />
      <install include="remove" />
      <install cmd='"%TEMP%\R-release.exe" /SILENT' >
           <download url='http://cran.r-project.org/bin/windows/base/R-release.exe' target="R-release.exe" />
           <exit code="any"/>
      <upgrade include="remove" />
      <upgrade include="install" />
      <remove cmd='"%COMSPEC%" /c for /d %r in ( "%PROGRAMFILES%\R\*.*" ) do if exist "%r\unins000.exe" "%COMSPEC%" /c "%r\unins000.exe" /silent'>
          <exit code="any" />

To automatically install some packages, add the following:

<check type="execute" path='"%COMSPEC%" /c for /d %r in ( "%PROGRAMFILES%\R\*.*" ) do if exist "%r\bin\rscript.exe" "%r\bin\rscript.exe" -e "installed.packages()" | find /c "r_pkg_name" > NUL'  condition="exitcodeequalto" value="0" />
<install cmd='"%COMSPEC%" /c for /d %r in ( "%PROGRAMFILES%\R\*.*" ) do if exist "%r\bin\rscript.exe" start /wait "r_pkg_name" "%r\bin\rscript.exe" "%SOFTWARE%\r\r_pkg_name.R"' >
    <exit code="any" />
<upgrade include="install" />

where r_pkg_name.R contains install.packages() commands like this (change repos to your nearest CRAN mirror):

install.packages("gbm", repos="http://cran.ms.unimelb.edu.au/")
install.packages("Design", repos="http://cran.ms.unimelb.edu.au/")
install.packages("rpart", repos="http://cran.ms.unimelb.edu.au/")