Learn R Programming

mvbutils (version 1.0.1)

formalize.package: Create a formal package skeleton from an informal package

Description

formalize.package is useful when you have a set of functions with flat-format documentation that you want to make into a formal package. It creates a bare-bones package with Rsource and Rd documentation ready for RCMD CHECK.

Usage

formalize.package()
 formalize.package( funs=find.funs( where), package, where=1, dir.=,
 description.file=, new.index=TRUE, README.goes.first=TRUE)

Arguments

funs
character vector, defaulting to all functions in where.
package
name to give test package-- see DETAILS for default.
where
position in search path to make into package.
dir.
directory to contain test package. Defaults to path attribute of search pos where
description.file
filename of template DESCRIPTION file. If this doesn't exist, a default DESCRIPTION file will be concocted.
new.index
should it create a new INDEX file using Rdindex
README.goes.first
if there's a function whose name starts with README, should its documentation file be renamed so that it's found first? See "Package structure details".

Details

A bare-bones package skeleton is created (no C code etc.) in directory dir.. The skeleton will have a DESCRIPTION file, a single Rsource file with name "<>.r" in the "R" subdirectory, and the individual function-by-function Rd files in the "man" subdirectory. More details of the package structure are given below. The recommended way to use formalize.package is to have your collection of functions as a task called e.g. my.proto.package, use cd(my.proto.package) to bring it to the top workspace, and then call formalize.package(). This will create the formal skeleton in the "my.proto.package" subdirectory of the task directory. The name of the package is determined by the package parameter, which will default to the obvious, as above. If package is not supplied and no sensible default can be deduced, there will be an error message. The gory details are: package defaults to the name attribute of search pos where, without preceding "package:" if any; if this is NULL, package defaults to the names attribute of the path attribute of search pos where, which will have been set if the thing being packaged is a task. The mvbutils and debug packages started life as simple tasks, automatically loaded by my .First as proto-packages using mlibrary. Eventually they acquired flat-format documentation-- informal at first, then massaged towards Rd format as CRAN release approached. I then used formalize.package and (repeatedly!) RCMD CHECK. Package structure details: All pre-existing files in the "man" and "R" subdirectories (only) will be removed. No other files or subdirectories are created or removed. You will certainly want to edit the DESCRIPTION file before actual CRAN release. By default, the Rsource file will only contain functions, but you can include other objects too by naming them in the funs argument. For functions, only source code will be included; in other words, any attributes except source are removed before printing. In particular, flat-format documentation in doc attributes does not go into the Rfile. However, it is used to create the Rd files, bydoc2Rd. If any of the Rd files starts with a period (e.g. ".dotty.name"), it will be renamed to "01.dotty.name.Rd" (to avoid some problems with rcmd). If README.goes.first is TRUE, any Rd file starting with README will be renamed 00README.... This will ensure that the README...function appears first in the "package manual", and top of the list when library(help=mypackage) is called.

See Also

cd, flatdoc, doc2Rd, README.mvbutils, make.usage.section, make.arguments.section