[R] Making a Package

michael watson (IAH-C) michael.watson at bbsrc.ac.uk
Tue Feb 15 23:30:16 CET 2005


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.

	-----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
	
	______________________________________________
	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