Building R package under Windows is easy but tricky. So here I summarize the procedure below step-by-step. For those who are interested in more advanced guidelines, please see the references below.
Getting Started: Installing Necessary Software
1. The R software
Install full package of R.
2. The minimal set of Unix utilities (R tools)
If the above link for R tools is dead. Try this one (R tools). Extract it, say in a directory C:\Rtools
3. Perl (A scripting language used by the R installer and checker)
Find the version for Windows. You need to install the most current version or the installation would fail.
4. The GNU compiler set (MinGW)
Choose full installation.
5. Microsoft html compiler
6. A TeX system (MikTex)
If you have another TeX system in your PC. You can ignore this step.
Change your PATH "environmental variable"
To set the path, right click on the "My Computer" icon on your desktop. Choose properties and click on the "advanced" tab. Click the "environmental variables" button and you should manually type in the following red Paths. The example Paths should look like the following:
C:\RTools\bin;C:\MinGW\bin;C:\Program Files\MiKTeX 2.5\miktex\bin;C:\Perl\bin\;C:\Program Files\R\R.2.4.0\bin;C:\Program Files\HTML Help Workshop;C:\WINDOWS\system32; C:\WINDOWS;C:\WINDOWS\System32\Wbem;
Make sure you have the 6 new PATHs added corresponding to the above 6 softwares. To see if you do everything properly, click "start" --> "run" and type "cmd." You will see a windows command console pumps out. Then you type followings:
R CMD --help
For each, you should see a list of description. If not, something is wrong.
I will not state the details about how to write a package, please see Writing R Extensions instead.
Once you have everything ready. You need to compile the help files for your package first. Go to the windows command console and type (say your package is called test and is under c:\working\test):
R CMD Rd2txt lm.Rd
R CMD Rdconv -t=html -o=lm.html lm.Rd
You have to do the above compilation for every Rd file you write. Once you've done, go to your package main directory:
R CMD check test
This will check your package. To create a pdf manual for your package, simply type:
R CMD Rd2dvi --pdf test
You will have a test.pdf. Put it under the doc directory (e.g., c:\working\test\inst\doc). Finally you can create the R package now.
R CMD build --binary --use-zip test
This will create a zip file test_00.00.zip. You can install this package in R by choosing "install package(s) from local zip files".
[NOTE] If you want your package compiled by CRAN to be cross platforms, you need to check if your package depends on any of the packages that are not available for other platforms. For instance, if your package depends on the BRugs package which is only available for Windows, it will not be compiled for other platforms either by CRAN.
1 hour ago