[R] Creating a R package for Windows XP

Jeffrey Pai jpai at cc.umanitoba.ca
Sun Jun 19 18:07:44 CEST 2005


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.


Best Regards!

Jeffrey Pai
L.A.H. Warren Professor




More information about the R-help mailing list