[R] writing a simple package in R 2.0 under Windows XP

John Fox jfox at mcmaster.ca
Sun Nov 7 16:24:20 CET 2004

Dear Patrick,

I've prepared some basic instructions and a batch file for building simple
packages under Windows and have given them to several people who have
experienced problems. I've hesitated to send them to this list since they
really just duplicate information available elsewhere, and because the batch
file probably could be improved.

Since there has been a rash of Windows package-building problems recently
(probably because it's no longer possible to bypass the package-building
tools), I've appended the instructions and batch file to this message in the
hope that they prove useful. Of course, comments and suggestions for
improvement are appreciated.


-------------- snip ------------

Building Simple Packages Under R for Windows

1. Links to tools and additional information are at

2. Make sure R is *not* installed under c:\Program Files (or in any location
with spaces in the path) and that it is installed with package-building
tools. I use c:\R for the installation; I'll assume this below -- make
changes as necessary. 

3. Download <http://www.murdoch-sutherland.com/Rtools/tools.zip> and unzip
e.g. to c:\Program Files\Utilities; put this directory at the beginning of
the path. (It may be necessary to copy sh.exe to c:\bin\sh.exe.)

4. Download Perl from
<http://www.activestate.com/Products/ActivePerl/Download.html> and install
it using defaults.

5. Download fptex from
and install it. Note: This requires a fast internet connection during the
installation. Don't install latex under c:\Program Files\!

6. Download HTML Help Workshop from
tml/hwmicrosofthtmlhelpdownloads.asp> and install it. Add c:\Program
Files\HTML Help Workshop to the path.

7. If you want to be able to compile old-style Windows help files (probably
not necessary) download Microsoft Help Workshop
<ftp://ftp.microsoft.com/softlib/mslfiles/hcwsetup.exe> and install it. Add
c:\Program Files\Help Workshop to the path.

8. Put my file make-package.bat in c:\R\rwxxxx\src (where xxxx is the
version, e.g., 2000). If necessary, edit this file to reflect the location
of the R installation. 

9. Open a DOS (command) window. CD to R\rwxxxx\src. Make sure that the
package source files are in the directory package-name under
R\rwxxx\src\library. Enter make-package package-name. Carefully examine the
log file etc. 

10. After this process is completed, you'll have both a tar.gz file with the
source package and a .zip file with the Windows binary package. Install the
latter from the "Packages -> Install package(s) from local zip files" menu
in the normal manner. 

-------------- make-package.bat ------------

cd c:\R\rw2000\src\library
del %1\INDEX
del %1\data\00Index
del %1\chm\*.* /Q

..\..\bin\R CMD build --force --binary --auto-zip %1
..\..\bin\R CMD build --force %1
..\..\bin\R CMD check %1

cd %1.Rcheck
dvipdfm %1-manual

notepad 00check.log


> -----Original Message-----
> From: r-help-bounces at stat.math.ethz.ch 
> [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of H 
> Patrick Giraudoux
> Sent: Sunday, November 07, 2004 9:34 AM
> To: r-help
> Subject: [R] writing a simple package in R 2.0 under Windows XP
> Dear listers,
> I have developped a set of functions that I would like to 
> package on a Windows XP plateform for some friends (this 
> would be more simple than to deliver them as a source text 
> file without handy help). I am working under Windows XP.
> Of course I have gone through the manual "Writing R 
> extension" and try to sort out what a most simple "packaging" 
> for beginner (without compiled code, etc...)  could be. I 
> also read http://www.rap.ucar.edu/staff/ericg/RWinBuild.html 
> It is very easy to build R packages in Windows (for Windows)...
> Perl has been installed and works fine C:\Perl (source 
> http://www.activestate.com/Products/ActivePerl/Download.html).
> R Tools have been installed: C:\Perl\Rtools (source: 
> http://www.murdoch-sutherland.com/Rtools/tools.zip)
> R tools functions delivered work fine (ex: ls, etc...) R has 
> been installed "at the root" of C:\ to avoid any blank in directory
> names: C:\R\rw2000
> The PATH has been defined as environment variable in Windows XP as: 
> C:\Perl\Rtools;C:\Perl\bin;...;C:\R\rw2000\bin
> A trial package named "AnExample" has been prepared as 
> indicated in the example of package.skeleton() of the library 
> "utils" and put in C:\
> from there I have typewritten:
> C:\>RCMD build AnExample
> With this result:
> Can't open perl script "C:\R\rw2000/bin/build": No such file 
> or directory
> I could catch that indeed 'build.exe' does not exist in this 
> directory (which is true...) and tried to find it somewhere 
> on my c: disk. 
> Unfortunately, this 'build' or 'build.exe' file does not 
> exist nor a 'check' file, nor any complementary command of Rcmd
> After some research hours (actually since yesterday...), I 
> cannot find where I have got wrong yet... and considering the 
> result, I am sure I got somewhere!
> Can somebody help me on this?
> Thanks in advance,
> Patrick Giraudoux
> 	[[alternative HTML version deleted]]
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! 
> http://www.R-project.org/posting-guide.html

More information about the R-help mailing list