package.skeleton(name, list, environment = .GlobalEnv, path=".")
Initialize the files for an R package. First load in all the objects to be included in the package into the current R session, then run the package.skeleton command. See the Building Packages tab on this blog for videos about building R packages.
- name – A character string for the name of the package.
- list – If only some objects in the current session should be included in the package, list them here in a character vector.
- environment – The environment where the objects are looked for. (Most users should leave this argument alone.)
- path – By default, the package will be saved in the current working directory. Change the path argument to specify a different place to save the package files.
Example. In the sample code below, four objects have been preloaded into the current R session. Then the package.skeleton function was used to initialize the package. This command creates a package folder in the current working directory that includes files for all of the objects in the current R session.
> ls()  "lmPlot" "marioKart" "myPDF" "myPNG" > package.skeleton("packageName") Creating directories ... Creating DESCRIPTION ... Creating Read-and-delete-me ... Saving functions and data ... Making help files ... Done. Further steps are described in './packageName/Read-and-delete-me'.
Tip. Several additional options are available in the package.skeleton function, including list to specify only a subset of objects in the current session for the package.