====== 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 [[http://www.murdoch-sutherland.com/Rtools/|this page]]. Also note: there is an online service ([[http://win-builder.r-project.org/|http://win-builder.r-project.org]]) for building and checking R packages for Windows. ==== Preparations ==== - Look at the [[http://cran.r-project.org/doc/manuals/R-admin.html#The-Windows-toolset|Windows toolset appendix]] in the [[http://cran.r-project.org/doc/manuals/R-admin.html|R Administration manual]]. - Go to the webpage http://www.murdoch-sutherland.com/Rtools/ - Download and install the "Rtools.exe" file. This includes: - A bunch of command-line tools - Perl - The MinGW compiler - You may also want: - [[http://msdn.microsoft.com/en-us/library/ms669985.aspx|Microsoft's HTML Help Workshop]] - [[http://www.miktex.org/|MikTeX]] - Make sure your PATH contains all of the right directories (e.g., that the R bin directory is correct). - Go to "Control Panel -> System." - Click on the tab "Advanced" and then on "Environment Variables." - Highlight "Path" at the bottom and click "Edit". - 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". - Extract the package source to a directory, say "c:\MyRpackages\qtl" - Go to the directory "c:\MyRpackages" - Type "R CMD build --binary qtl" - A file like "qtl_0.98-52.zip" should be created. ----