[R] How to pack my stuff into a package (library, collection)?

Tribo Laboy tribolaboy at gmail.com
Mon Apr 7 15:33:06 CEST 2008


On Mon, Apr 7, 2008 at 8:02 PM, Duncan Murdoch <murdoch at stats.uwo.ca> wrote:
> Tribo Laboy wrote:
>
> > Hi Simon,
> >
> > I did the example given in package.skeleton
> >
> > f <- function(x,y) x+y
> > g <- function(x,y) x-y
> > d <- data.frame(a=1, b=2)
> > e <- rnorm(1000)
> >
> > package.skeleton(list=c("f","g","d","e"), name="mypkg")
> >
> >
> > then tried:
> >
> > library(mypkg)
> >
> > Error in library(mypkg) : there is no package called 'mypkg'
> >
> >
> > After checking the directory structure, I found the "package" 'mypkg'
> > placed under 'bin' sub-directory. I moved it to 'library', where all
> > of the CRAN downloaded packages are and this is what I get:
> >
> >
> >
> > > library(mypkg)
> > >
> > >
> > Error in library(mypkg) :
> >  'mypkg' is not a valid package -- installed < 2.0.0?
> >
> >
> > What am I missing?
> >
> >
> >
>  You created the source code for a package, but it needs some work to
> install it.  On Windows that means installing the Rtools collection and
> running "Rcmd INSTALL pkgdir" from the Windows command line (what some
> people call "the DOS box").
>
>  At some point I'm sure we'll include those tools with R, but it will more
> or less double the size of the download.  We've been reluctant when a lot of
> our users are on slow connections, and most won't need those tools.
>
>  Duncan Murdoch
>
>


Hi Duncan,


Thanks for your reply. I checked the Rtools and the other relevant
tools. I will most probably install them, although unwillingly.
Unwillingly, because I like my current setup very much, which is a
portable installation of R. I run it on the 5 different machines that
I use and it is very easy to sync no mater where I install new or
updated packages. I will probably have to designate one of the
machines as a development machine and the others will be run-only, but
this is very similar to compiled languages. Is there any way to set
them up inside the main R directory structure, independent of the
operating system, variables, etc.?

Once again, it would be very helpful to clarify what is it that is
needed to run my R-files and what INSTALL does (I did ?INSTALL, but I
am none the wiser). As a user I can do without all the bells and
whistles of a HTML or chm-help and just some command line parsing of
the Rd help files is just fine. Obviously, I can run my functions when
"sourced" and I do not interface to FORTRAN or C, so I do not
understand what more is needed. Is it a namespace issue or just help
file compilation? Whatever it is, I suspect that this rigid INSTALL
and package build process is very helpful to enforce good quality
packages on CRAN with good quality documentation. But isn't it an
overkill for average Joe Programmer, who will never submit
'joes_weighted_mean' package to CRAN?

Anyway, if you'd have some piece of advice, I'd really appreciate it.

Regards,

TL



More information about the R-help mailing list