\HeaderA{package.skeleton}{Create a Skeleton for a New Source Package}{package.skeleton}
\keyword{file}{package.skeleton}
\keyword{utilities}{package.skeleton}
\begin{Description}\relax
\code{package.skeleton} automates some of the setup for a new source
package.  It creates directories, saves functions, data, and R code files to
appropriate places, and creates skeleton help files and a
\file{Read-and-delete-me} file describing further steps in packaging.
\end{Description}
\begin{Usage}
\begin{verbatim}
package.skeleton(name = "anRpackage", list,
                 environment = .GlobalEnv,
                 path = ".", force = FALSE, namespace = FALSE,
                 code_files = character())
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{name}] character string: the package name and directory name for
your package.
\item[\code{list}] character vector naming the \R{} objects to put in the
package.  Usually, at most one of \code{list}, \code{environment},
or \code{code\_files} will be supplied.  See \sQuote{Details}.
\item[\code{environment}] an environment where objects are looked for.  See
\sQuote{Details}.
\item[\code{path}] path to put the package directory in.
\item[\code{force}] If \code{FALSE} will not overwrite an existing directory.
\item[\code{namespace}] a logical indicating whether to add a name space for
the package.  If \code{TRUE}, a \code{NAMESPACE} file is created
to export all objects whose names begin with a letter, plus all S4
methods and classes.
\item[\code{code\_files}] a character vector with the paths to R code files to
build the package around.  See \sQuote{Details}.
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
The arguments \code{list}, \code{environment}, and \code{code\_files}
provide alternative ways to initialize the package.  If
\code{code\_files} is supplied, the files so named will be sourced to
form the environment, then used to generate the package skeleton.
Otherwise \code{list} defaults to the non-hidden files in
\code{environment} (those whose name does not start with \code{.}),
but can be supplied to select a subset of the objects in that
environment.

Stubs of help files are generated for functions, data objects, and
S4 classes and methods, using the \code{\LinkA{prompt}{prompt}},
\code{\LinkA{promptClass}{promptClass}},  and \code{\LinkA{promptMethods}{promptMethods}} functions.

The package sources are placed in subdirectory \code{name} of
\code{path}.  If \code{code\_files} is supplied, these files are
copied; otherwise, objects will be dumped into individual source
files.
The file names in \code{code\_files} should  have suffix \code{".R"} and
be in the current working directory.

The  filenames created for source and documentation try to be valid
for all OSes known to run R.  Invalid characters are replaced by
\samp{\_}, invalid names are preceded by \samp{zz}, and finally the
converted names are made unique by \code{\LinkA{make.unique}{make.unique}(sep =
    "\_")}.  This can be done for code and help files but not data files
(which are looked for by name). Also, the code and help files should
have names starting with an ASCII letter or digit, and this is
checked and if necessary \code{z} prepended.

When you are done, delete the \file{Read-and-delete-me} file, as it
should not be distributed.
\end{Details}
\begin{Value}
Used for its side-effects.
\end{Value}
\begin{References}\relax
Read the \emph{Writing R Extensions} manual for more details.

Once you have created a \emph{source} package you need to install it:
see the \emph{R Installation and Administration} manual,
\code{\LinkA{INSTALL}{INSTALL}} and \code{\LinkA{install.packages}{install.packages}}.
\end{References}
\begin{SeeAlso}\relax
\code{\LinkA{prompt}{prompt}}, \code{\LinkA{promptClass}{promptClass}}, and
\code{\LinkA{promptMethods}{promptMethods}}.
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
require(stats)
## 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(list=c("f","g","d","e"), name="mypkg")

\end{ExampleCode}
\end{Examples}

