[R] Making a Package

Gabor Grothendieck ggrothendieck at myway.com
Wed Feb 16 08:09:55 CET 2005



michael watson (IAH-C <michael.watson <at> bbsrc.ac.uk> writes:

: 
: I follow the guide here and it never fails:
: 
: http://www.biostat.jhsph.edu/~kbroman/Rintro/Rwinpack.html
: 
: So if I have the MyPackage directory, that was created with package.skeleton 
and subsequently edited, I
: will cd to the directory that contains the MyPackage directory and:
: 
: R CMD INSTALL --build MyPackage
: 
: MyPackage_1.0.zip will be created.  Then install using the menus.

Its faster to do:

  Rcmd install mypackage

followed by 

  library(mypackage) # done from R

as it eliminates the install using menus part.  (Also, except
in the initial development, its common to have a production and 
development version in which case one can usefully keep the latter 
in a separate library as explained below.)  The above is done repeatedly 
and then one checks it using 'Rcmd check mypackage' and further 
testing until it passes the check.  This check step should not be 
ignored as its a key step for quality in the package building 
process.  Finally after its all working one can produce the .zip and 
.tar.gz files using 'Rcmd build mypackage' and 'Rcmd build 
--binary mypackage', respectively.

: 
: 	-----Original Message----- 
: 	From: r-help-bounces <at> stat.math.ethz.ch on behalf of Gabor 
Grothendieck 
: 	Sent: Tue 2/15/2005 9:59 PM 
: 	To: r-help <at> stat.math.ethz.ch 
: 	Cc: 
: 	Subject: Re: [R] Making a Package
: 	
: 	
: 
: 	KKThird <at> Yahoo.Com <kkthird <at> yahoo.com> writes:
: 	
: 	:
: 	: Hello.
: 	: I have what I know to be a simple question, but never having done 
anything
: 	like this it is
: 	: pretty tough.
: 	:
: 	: I'm trying to write an R package. I have a collection of functions 
that I
: 	loaded into R and
: 	: then used package.skeleton(). After editing everything in the 
resulting
: 	folder, call it
: 	: NewPackage, I tried to follow along with some instructions I found 
for
: 	Windows users.
: 	:
: 	: I installed ActivePearl to the C drive, placed the unzipped Rtools 
folder,
: 	tools, there also
: 	: (is placing it there all that is necessary; I couldn't find anything
: 	to "install" tools), and
: 	: I'm using R 2.00 (also installed on the C drive) on a Win-XP machine.
: 	:
: 	: My understaning is that (since I have no C, Fortran, etc., code) I 
can move
: 	the NewPackage
: 	: folder (with all of the edited material) to the C:\r\rw2000
\src\library
: 	folder and then open
: 	: MS-Dos in C:\r\rw2000\src\gnuwin32 and type: make pkg-NewPackage. 
After
: 	that, a folder called
: 	: NewPackage should be placed in the C:\r\rw2000\library and from 
there loaded
: 	into R and/or zipped and
: 	: distributed. If everything I have said is correct (which it may not 
be) then
: 	I'm
: 	: stuck. When I type 'make pkg-NewPackage' in the C:\r\rw2000
\src\gnuwin32
: 	directory I get
: 	: "'make' is not recognized as an internal or external command, 
operable
: 	program or batch file."
: 	:
: 	: I've tried to use "Writing R Extensions," but I could only follow 
part of
: 	what it was saying
: 	: and got confused as to what was done on Windows and what was done on 
Unix
: 	machines.
: 	: I know this is probably an easy question, but it has proved 
difficult for me
: 	to figure out how
: 	: to make my own package.
: 	: Thanks, Ken
: 	
: 	
: 	Make sure that:
: 	- the tools and the R bin folders are in your path
: 	- you have installed fptex or MiKTeX, perl and the Microsoft help 
compiler
: 	  (MiKTeX is a bit harder to install but I otherwise prefer it.  If you
: 	  are writing vignettes you must use MiKTeX.)
: 	- you have read:
: 	   Writing R Extensions Manual
: 	   http://www.murdoch-sutherland.com/Rtools/
: 	
: 	I am assuming here that your R installation is in \Program 
Files\R\rw....
: 	
: 	1. Assuming your source package tree is in \Rpkgs\mypackage
: 	   then in the Windows cmd line:
: 	
: 	        cd \Rpkgs
: 	        Rcmd install mypackage
: 	
: 	   which will install it to your \Program 
Files\R\rw....\library\mypackage
: 	   or if you want to install it to a separate library:
: 	
: 	        cd \Rpkgs
: 	        md library
: 	        Rcmd install -l library mypackage
: 	
: 	2. Now in R:
: 	
: 	        library(mypackage)
: 	        ... test it out ...
: 	
: 	or if you installed it to a separate library:
: 	
: 	        library(mypackage, lib.loc = "/Rpkgs/library")
: 	
: 	3. Once it seems reasonably ok,  see if it passes Rcmd check:
: 	
: 	        cd \Rpkgs
: 	        Rcmd check mypackage
: 	
: 	   and fix it up until it does.
: 	
: 	4. Now create versions for UNIX and Windows that you can distribute:
: 	
: 	        cd \Rpkgs
: 	        Rcmd build mypackage
: 	        Rcmd build mypackage --binary




More information about the R-help mailing list