Skip to content

writing a simple package in R 2.0 under Windows XP

6 messages · Patrick Giraudoux, Gabor Grothendieck, Brian Ripley +1 more

#
H Patrick Giraudoux <patrick.giraudoux <at> univ-fcomte.fr> writes:

: 
: 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?
: 

There have been relevant discussions on r-devel just this weekend.
Have a look at those archives 

   http://news.gmane.org/gmane.comp.lang.r.devel

and this post in particular:

   http://article.gmane.org/gmane.comp.lang.r.devel/1653
#
On Sun, 7 Nov 2004, H Patrick Giraudoux wrote:

            
Did you want to package up the sources of a package you haven't tested?
Surely you wanted to install and test it first?
A Perl script is not `build.exe': this really is just 'build'.
You apparently DEselected the installation of the source package tools 
when you installed R.  You need to go back and install them.
You apparently missed the comment about HTML mail in the posting guide.
#
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.

Regards,
 John

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

Building Simple Packages Under R for Windows

1. Links to tools and additional information are at
<http://www.murdoch-sutherland.com/Rtools/>.

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
<http://www.ctan.org/tex-archive/systems/win32/fptex/current/TeXSetup.exe>
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
<http://msdn.microsoft.com/library/default.asp?url=/library/en-us/htmlhelp/h
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

---------------------------------------------
#
John Fox <jfox <at> mcmaster.ca> writes:
I just have been through building packages with XP this weekend.
I used the default R installation which installs R 2.0.1 beta under 

   C:\Program Files\R\rw2001beta

and had no problems with using that pathname so I believe this warning 
is no longer needed, at least with XP and R 2.0.1.  That would 
slightly simplify installation since it allows one to use the 
default installation.

Uwe pointed out to me that one should use forward slashes rather
than backward slashes on path names when using R CMD ... .
I think you have avoided the need for pathnames in your script
altogether but thought I would mention it since it was a significant 
gotcha for me.
I used MiKTeX which is a pain since there is some configuration
to be done to use it with R although it works well once MiKTeX 
is so configured.  The murdoch link you posted describes the 
configuration steps.  Someone else also 
mentioned to me privately I should have tried fptex and would
have avoided these configuration problems.  (It occurred to me
that if the Rd.sty file could be added to the MiKTeX repository
online where MiKTeX gets its other .sty files then it could be 
pulled out from there and the MiKTeX configuration would not have 
to be modified to access the R directory tree.)
It was also pointed out to me that --force
is an important switch; however, I did not use it and did
not notice any problems.  I also did not use --auto-zip.
Any comments on the importance of these?

Andy advised me to first use:

   R CMD install ...

to get my software going and that advice seemed particularly useful 
since it allowed me to install, run and test my software as a package 
in R so that I could get it in better shape before submitting it to 
R CMD check ... and R CMD build ... --binary .
#
Dear all,

Following John Fox and Brian Ripley instructions, things come better.  I 
still get errors but they just come at the first step from unappropriate 
DESCRIPTION file (which was expected: I just wanted to check if the 
software installation was OK for building packages with the "crude" 
AnExample from the package.skeleton() doc. I can "quitely" come back to the 
"Writing R extension guide" and work on it now).

One mishaps that can be worthy to bold for other listers is that I did not 
select the installation of the source package tools in an early 
installation of R (it is unselected by default with rw2000.exe). Advised to 
re-install R taking this into account for those who gradually try to move 
from function development to package writing...

Thanks for the hints kindly provided even a Sunday,

Patrick Giraudoux



A 10:24 07/11/2004 -0500, vous avez ??crit :