In this chapter we describe the anatomy of a package: the types of files and their organization into various directories.
The following diagram depicts three possible (hypothetical) filestructures for a package. From a minimal version, to the default contents created by
"devtools", to a more sophisticated structure.
9.3 Minimal Package
The first option is what it’s considered to be a minimal package.
Every package must have at least the following four components:
Without any of these four elements, you won’t be able to create a valid R package.
9.4 Default devtools setting
The second option corresponds to the default structure generated by RStudio when you use an RStudio project—via the package
In addition to the files and directories of the previous option, now there are two more files:
- A text file
.Rproj(i.e. an RStudio project file)
- A text file
9.5 Our working example
The third option is the actual structure for our working example.
Starting with a default structure, we can add more elements like a
README.md files, and directories for
vignettes/. The extra directory
inst/ is generated in the building process.
You can add more files and directories to make a more complex and robust package. However, to keep a focused scope on this book we will concentrate on the above structure.
Make a donation
If you find this resource useful, please consider making a one-time donation in any amount. Your support really matters.