[R] Problems creating packages.

Robert Robinson tehflash at gmail.com
Fri Jun 23 22:20:57 CEST 2006


I'm creating my own package for personal and I'm having trouble
getting it to a point where R (v 2.3.1) will recognise it.  I've
followed two different tutorials for how to create the package
structure and the DESCRIPTION file (
http://web.maths.unsw.edu.au/~wand/webcpdg/rpack.html ,
http://www.maths.bris.ac.uk/~maman/computerstuff/Rhelp/Rpackages.html#Lin-Lin
).  I'm still getting errors where when I try to load the library in R
by using library(samp) I get an error:

Error in library(samp) : 'samp' is not a valid package -- installed < 2.0.0?

And when I use the library() call I get this:

samp                    ** No title available (pre-2.0.0 install?) **

I'm not really sure where to go, I've looked throgh the huge document
on how to create an R package on the site but that didn't help.  Just
for reference I'm going to add a sample of everything becasue at this
point I really don't know what it is.  Basic procedure is what they
layout in the tutorials I linked above.  First I made the files,
followed by calling R CMD build samp on the samp directory that holds
all my files, followed by calling sudo R CMD INSTALL samp_0.1-1.tar.gz
 I don't get errors on either of those calls.  When I call R CMD check
samp I get this output:

* checking for working latex ...sh: latex: command not found
 NO
* using log directory '/home/rrobinson/myrpac/samp.Rcheck'
* using Version 2.3.0 (2006-04-24)
* checking for file 'samp/DESCRIPTION' ... OK
* this is package 'samp' version '0.1-1'
* checking package dependencies ... OK
* checking if this is a source package ... ERROR
Only *source* packages can be checked.

Here is what my file structure looks like:

.:
DESCRIPTION  man  R

./man:
bootstrap.rd  hessian.rd         loglikelihood.rd  stdeviation6.rd
freq.rd       ks.rd              score6.rd         stdeviation.rd
hessian6.rd   loglikelihood6.rd  score.rd

./R:
bootsample.r  hessian6.r  loglikelihood6.r  score6.r        stdeviation.r
firstlib.r    hessian.r   loglikelihood.r   score.r
freq.r        ks.r        Prob.r            stdeviation6.r

here is what my DESCRIPTION file looks like:

Package: samp
Title: R custom simulation package
Version: 0.1-1
Date: 2006-06-23
Author: Cheng Peng <*********************>
Maintainer: ************** <tehflash at gmail.com>
Description: Functions for custom simulation, includes a score and
        loglikelihood function.
License: GPL (version 2 or later)
Built: R 2.3.0; i686-pc-linux-gnu; 2006-06-16 11:28:36; unix
Packaged: Fri Jun 16 11:36:02 2006; root

Here is a sample .r file format:

###########################################################################
#
#        Freq function returns the frequencies of numerical vectors
#
###########################################################################

  freq = function(x1,x2,x3){
     nn1=rep(0, length(x))
     nn2=rep(0, length(x))
     nn3=rep(0, length(x))
     for ( i in 1:length(x)){
         nn1[i]=sum(x[i]==x1)
         nn2[i]=sum(x[i]==x2)
         nn3[i]=sum(x[i]==x3)
     }
   mm = as.matrix(rbind(nn1,nn2,nn3))
   mm
  }

Here is a sample man page format:

\name{freq}
\alias{freq}
\title{Frequencies of numerical vectors}
\description{
   Freq function returns the frequencies of numerical vectors
}
\usage{
freq(x1,x2,x3)
}
\arguments{
   \item{x1}{numerical vector}
   \item{x2}{numerical vector}
   \item{x3}{numerical vector}
}
\keyword{custom}


Thanks to anyone who can help me solve this.



More information about the R-help mailing list