[R] Creating a R package for Windows XP

Gabor Grothendieck ggrothendieck at gmail.com
Sun Jun 19 19:11:29 CEST 2005


On 6/19/05, Prof Brian Ripley <ripley at stats.ox.ac.uk> wrote:
> You have created a source package, and c:/R/rw2010/library is not the
> right place for a source package.  You need to move it somewhere else and
> INSTALL it, as described in the rw-FAQ.  (You need to move it because it
> would be installed into that directory and you are not allowed to clobber
> the sources by doing so.)
> 
> Both `Writing R Extensions' and `R Installation and Administration'
> manuals give more details: in particular the latter describes the tools
> you will need to collect.
> 
> On Sun, 19 Jun 2005, Jeffrey Pai wrote:
> 
> > Hi:
> >
> > I'm trying to create a package to pass to someone else to use a group of
> > functions with help files.  I'm working on Windows XP.
> >
> > Step One:  I use the example
> >
> >>       ## two functions and two "data sets" :
> >>       f <- function(x,y) x+y
> >>       g <- function(x,y) x-y
> >>       d <- data.frame(a=1, b=2)
> >>       e <- rnorm(1000)
> >>
> >>       package.skeleton(name="mypkg", list=c("f","g","d","e"),
> > + path="c:/R/rw2010/library", force=TRUE)
> > Creating directories ...
> > Creating DESCRIPTION ...
> > Creating READMEs ...
> > Saving functions and data ...
> > Making help files ...
> > Created file named 'c:/R/rw2010/library/mypkg/man/f.Rd'.
> > Edit the file and move it to the appropriate directory.
> > Created file named 'c:/R/rw2010/library/mypkg/man/g.Rd'.
> > Edit the file and move it to the appropriate directory.
> > Created file named 'c:/R/rw2010/library/mypkg/man/d.Rd'.
> > Edit the file and move it to the appropriate directory.
> > Created file named 'c:/R/rw2010/library/mypkg/man/e.Rd'.
> > Edit the file and move it to the appropriate directory.
> > Done.
> > Further steps are described in c:/R/rw2010/library/mypkg/README
> >
> >
> > Step Two:  I load the package "mypkg" from "Packages - load package..." and
> > get
> >
> >> local({pkg <- select.list(sort(.packages(all.available = TRUE)))
> > + if(nchar(pkg)) library(pkg, character.only=TRUE)})
> > Error in library(pkg, character.only = TRUE) :
> >        there is no package called 'mypkg'
> >
> > The DESCRIPTION file in /library/mypkg contains:
> >
> > Package: mypkgType: Package
> > Title: What the package does (short line)
> > Version: 1.0
> > Date: 2005-06-19
> > Author: Who wrote it
> > Maintainer: Who to complain to <yourfault at somewhere.net>
> > Description: More about what it does (maybe more than one line)
> > License: What license is it under?
> >
> > The first line looks suspicious so I change it to two lines
> >
> > Package: mypkg
> > Type: Package
> >
> > I load the package again and get
> >
> >> local({pkg <- select.list(sort(.packages(all.available = TRUE)))
> > + if(nchar(pkg)) library(pkg, character.only=TRUE)})
> > Error in library(pkg, character.only = TRUE) :
> >        'mypkg' is not a valid package -- installed < 2.0.0?
> >
> >
> > Step-Three:  I read the README file under \mypkg and do
> >
> >> R CMD build
> > Error: syntax error
> >
> >
> > Am I on the right track?  I've read several instructions regarding creating
> > R packages for Windows on web and installed several files.  I must be
> > missing something.
> > Thank.

You need to ensure that all the tools are installed and that you have
set your path correctly at which point:
   Rcmd build mypkg --binary
is the minimum to build package mypkg 
(assuming you constructed it right). 

It will be necessary to spend some time to get up speed by reading
all of the following:
- releveant portions of the R manual:    Writing R Extensions
- several short guides found by googling for:  building making R packages
- check out first hit when googling for:  Rtools
- download the source to some other packages as examples




More information about the R-help mailing list