[R] Creating a minimal package
Uwe Ligges
ligges at statistik.uni-dortmund.de
Mon Jul 12 15:14:27 CEST 2004
Gabor Grothendieck wrote:
> Uwe Ligges <ligges <at> statistik.uni-dortmund.de> writes:
>
> :
> : Gabor Grothendieck wrote:
> :
> : > Duncan Murdoch <dmurdoch <at> pair.com> writes:
> : >
> : > : On Sun, 11 Jul 2004 21:28:44 +0000 (UTC), Gabor Grothendieck
> : > : <ggrothendieck <at> myway.com> wrote:
> : > :
> : >
> : > : >1. when I run skeleton.package realize that I must use the arg
> : > : > path = "library"
> : > : > The example that is shown there appears to omit that.
> : > :
> : > : The default is to put it in the current directory. The assumption is
> : > : that you started R where you want to work, or have switched to that
> : > : directory later. This is usually true for Unix users, but generally
> : > : not for Windows users.
> : > :
> : > : I'm not sure what sort of change to make here. path = "library"
> : > : (literally) won't usually work, because it won't try to create the
> : > : directory. Suggestion?
> : >
> : > Perhaps we could use:
> : >
> : > path = .libPaths()[[1]]
> : >
> : > as the default value of path in package.skeleton.
> :
> : Actually, that's a bad idea, because you don't want a source package in
> : your binary library tree.
> : I'm really happy with the default and the documentation which tells us
> : about the "path" argument. Most (all?) functions I know do write to the
> : current working directory. You do not want another default for
> : write.table() et al. to write the data to, do you?
>
> The objective should be that creating a package is as easy as this:
>
> f <- function()1; g <- function()2; d <- 3; e <- 4:5
> package.skeleton(list=c("f","g","d","e"), name="AnExample")
> library(AnExample)
> f()
>
> which means that the package needs to be inserted where library will
> find it. It should not be necessary to have an understanding of this.
>
OK, I understand what you are going to do, but in that case you can use
dump() into an *.R or save() into an *.RData file and use
source()/load() to load it again. I don't see any advantage of a package
if you don't want to modify documentation or other stuff in the package.
Also, you would need the tools to make a binary package from the source
package somewhere. package.skeleton() is clearly not intended to be used
for that purpose, but to create the template for your source package.
Hence the default should not be changed.
Uwe Ligges
More information about the R-help
mailing list