Create a Skeleton for a New Source Package
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
package.skeleton(name = "anRpackage", list, environment = .GlobalEnv, path = ".", force = FALSE, code_files = character())
- character string: the package name and directory name for your package.
- character vector naming the Robjects to put in the
package. Usually, at most one of
code_fileswill be supplied. See
- an environment where objects are looked for. See
- path to put the package directory in.
FALSEwill not overwrite an existing directory.
- a character vector with the paths to R code files to
build the package around. See
provide alternative ways to initialize the package. If
code_files is supplied, the files so named will be sourced to
form the environment, then used to generate the package skeleton.
list defaults to the objects in
(including those whose names start with
.), 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
If an object from another package is intended to be imported and
re-exported without changes, the
should be used after
to generate a simple help file linking to the original one.
The package sources are placed in subdirectory
code_files is supplied, these files are
copied; otherwise, objects will be dumped into individual source
files. The file names in
code_files should have suffix
".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 _,
invalid names are preceded by zz, names are converted to lower
case (to avoid case collisions on case-insensitive file systems) and
finally the converted names are made unique by
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
Functions with names starting with a dot are placed in file
When you are done, delete the
- Used for its side-effects.
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) owd <- getwd() setwd(tempdir()) package.skeleton(list = c("f","g","d","e"), name = "mypkg") setwd(owd)