unpackage: Convert existing source package into task package

unpackageR Documentation

Convert existing source package into task package

Description

Converts an existing source package into a task package. A subdirectory with the package name will be created under the current working directory, and will be populated with a ".RData" file and various other files/directories from the source package. All Rd files will be turned into flat-format help in the ".RData", either attached to functions or as stand-alone "*.doc" text objects, as per help2flatdoc. The subdirectory will also be made into a task, i.e. it will be added to the "tasks" vector in the current workspace that cd uses to keep track of the task hierarchy.

Roxygen pre-function comments are by default removed; see keep_Roxygen argument.

Usage

unpackage(spath, force = FALSE, alias=x,
    drop_Conly=TRUE, trust_importFrom=FALSE,
    zap_Cloaders= TRUE, keep_Roxygen= FALSE)

Arguments

spath

where to find the source package

force

if TRUE, overwrite any previous contents of task package without prompting.

alias

if you don't want the package to go into a folder (and task) with its obvious name, then set eg alias="temp_mypack"; useful for comparing versions.

drop_Conly

?exclude pure R wrappers of dot-Call/dot-External? Normally (I presume) those are auto-generated, and will be regenerated by pre.install in the "Cloaders" business, so this should be OK.

trust_importFrom

Whether to force-copy all importFrom() NAMESPACE directives into the maintained package. Used to be TRUE by default, but I think FALSE is better...

zap_Cloaders

whether to remove run_Cloaders_<mypack>, if it's present; though it shouldn't really be, I think, cos it seems to prevent installation. (It's regenerated by pre.install automatically.) IOW, run_Cloaders_<mypack> should be removed before a git push unless you are using mvbutils package building system.

keep_Roxygen

I thoroughly dislike Roxygen, and my pref is to generate the help for each function— stored in its docattr attribute— directly from the dot-Rd file. If anyone ever really wants Roxygen, they can try Rd2Roxygen (beware the bugs...). So my default is FALSE, but if you set TRUE then unpackage will make a big effort to store the original Roxybollocks.

Details

The NAMESPACE file won't be copied; instead, it will be auto-generated by pre.install. Therefore, some features of the original NAMESPACE may be lost. You can either copy the NAMESPACE manually (in which case, you'll need to maintain it by hand), or write a "pre.install.hook.MYPACK" function.

The DESCRIPTION file becomes a character vector called e.g. <mypack>.DESCRIPTION, of class "cat" (see as.cat).

Functions in the ".RData" may be saved with extra attributes, in particular "doc" (deduced from a dot-Rd file) but perhaps other things too that they acquire after the package code is sourced. Attributes that are character vector will acquire class "docattr", so that they won't be fully displayed during default printing of the function; to see them, use e.g. as.cat( attr( myfun, "myatt")) or unclass( attr( myfun, "myatt")) or, if you are using the atease package, just as.cat( myfun@myatt). Editing the function with fixr will display the character attributes in full.

Any environment objects found in the package's environment (its namespace environment) will be dropped from the ".RData" file, with a warning; this is to avoid dramas on reloading.

See Also

pre.install, mvbutils.packaging.tools


mvbutils documentation built on May 25, 2026, 5:09 p.m.

Related to unpackage in mvbutils...