October 2012
Beginner to intermediate
721 pages
21h 38m
English
Building your own packages is a good idea if you want to share code or data with other people, or if you just want to pack it up in a form that’s easy to reuse. This section explains the easy way to create your own packages.
To build a package, you need to place all the package
files (code, data, documentation, etc.) inside a single directory. You
can create an appropriate directory structure using the R function
package.skeleton:
package.skeleton(name = "anRpackage", list,
environment = .GlobalEnv,
path = ".", force = FALSE, namespace = FALSE,
code_files = character())This function can also copy a set of R objects into that
directory. Here’s a description of the arguments to package.skeleton.
| Argument | Description | Default |
|---|---|---|
| name | A character value specifying a name for the new package | “anRpackage” (as a side note, this may be the least-useful default value for any R function) |
| list | A character vector containing names of R objects to add to the package | |
| environment | The environment in which to evaluate list | .GlobalEnv |
| path | A character vector specifying the path in the file system | “.” |
| force | A Boolean value specifying whether to overwrite files, if
a directory name already
exists at path | FALSE |
| namespace | A Boolean value specifying whether to add a namespace to the package | FALSE |
| code_files | A character vector specifying the paths of files containing R code | character() |
For this book, I created a package called nutshell containing most of the data sets used
in this book:
> ...
Read now
Unlock full access