[R] Making a Package
Gabor Grothendieck
ggrothendieck at myway.com
Tue Feb 15 22:59:12 CET 2005
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