User Tools

Site Tools


lab:people:build_r_packages_for_windows

Build R packages

Step1: generate a skeleton

package.skeleton(name="bmem", code_files="bmem.R")

Step 2: edit DESCRIPTION file

Building R packages in Windows


Disclaimer: The instructions below describe what I've been doing to compile an R package for Windows. Check out the files “src/gnuwin32/INSTALL” and “src/gnuwin32/readme.packages” in the R source distribution for the official (and recommended) approach. Most importantly, see this page.

Also note: there is an online service (http://win-builder.r-project.org) for building and checking R packages for Windows.

Preparations

  1. Download and install the “Rtools.exe” file. This includes:
    1. A bunch of command-line tools
    2. Perl
    3. The MinGW compiler
  2. You may also want:
  3. Make sure your PATH contains all of the right directories (e.g., that the R bin directory is correct).
    1. Go to “Control Panel → System.”
    2. Click on the tab “Advanced” and then on “Environment Variables.”
    3. Highlight “Path” at the bottom and click “Edit”.
    4. In the character string in “Variable Value”, you want “c:\Rtools\bin;c:\Rtools\perl\bin;c:\Rtools\MinGW\bin;c:\R\bin” and then any other stuff at the end. (Most problems I've experienced have been due to incorrect directories here, or an incorrect order in the directories.)

Building an R package in Windows

With the latest versions of R, this is easy. I'll use, as an example, my own package, “qtl”.

  1. Extract the package source to a directory, say “c:\MyRpackages\qtl”
  2. Go to the directory “c:\MyRpackages”
  3. Type “R CMD build –binary qtl”
  4. A file like “qtl_0.98-52.zip” should be created.


Page Tools