Skip to content
Prev 326709 / 398503 Next

Help with installing a .tar.gz package on windows

We are all beginners at something.  Telling Windows users that building packages
from source is beyond them is walling them off from a very productive area.

Here is how I set things up to build R packages from either a source directory
or a tar.gz file on Windows.

(a) Download Rtools for your version of R from Duncan Murdoch's site (or whereever
it is) and install it.  I install it into C:\Rtools\Rtools-i.j.k (where i.j.k is currently 3.0.x).
I select 'no' if the installer asks whether I want to update my global PATH variable
because I need to be able to compile packages for various version and dialects of S (R, S+, TERR).

(b) Make a text file in C:\Rtools\Rtools-3.0.x called SETPATH.bat containing the following
::: start of file 
: You should set the following 2 variables to say where you installed Rtools and R itself
set RTOOLS_HOME=C:\Rtools\Rtools-3.0.x
set R_HOME=C:\Program Files\R\R-3.0.1

: You may have to change gcc-4.6.3 to something else as the version supplied
: in Rtools-x.y.z changes, but the following works now.
set RTOOLS_PATH=%RTOOLS_HOME%\bin;%RTOOLS_HOME%\MinGW\bin;%RTOOLS_HOME%\gcc-4.6.3\bin
set R_PATH=%R_HOME%\bin

set PATH=%RTOOLS_PATH%;%R_PATH%;%PATH%
::: end of file

You only have to do steps (a) and (b) once for a given version of R.

(c) When you want to compile a package, make a new DOS commands window (run cmd.exe)  and type
     C:\Rtools\Rtools-3.0.x\SETPATH.bat
at the DOS prompt to run the bat file that you created in (b).  cd to the directory containing the package source and type (still at the DOS prompt)
    R CMD INSTALL myPackage.tar.gz
or
    R CMD INSTALL myPackage
depending on if you have a tar.gz file or a directory containing the package source.

Test the package by typing
    R
and when you get the R prompt
    library(myPackage)

If you want to use things like MiKTeX or InnovSetup add their bin directories to PATH
in that SETPATH.bat file.

There are other paths to build a package from source, but see if this one works.

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com