Appendix C — Packages FAQ

C.1 Can an .Rproj file convert an R project into an R package?

The technical answer is no, because the .Rproj only activates the Build pane in the IDE. The tools in the Build pane are directly connected to the devtools package (hence the PackageUseDevtools: Yes in the .Rproj file).

The seven mandatory fields are required in the DESCRIPTION to have a functioning R package.

C.2 I have a DESCRIPTION file with the required fields, but where is the Build pane?

If the mandatory fields are added to the DESCRIPTION, but the .Rproj file doesn’t have any of the package configuration fields, then the Build pane will not be displayed (see example below):

(a) Build pane tools
Figure C.1: Mandatory DESCRIPTION fields with package configuration in .Rproj file

C.3 What if my .Rproj file is configured to work with a package, but my DESCRIPTION file is missing one (or more) of the required fields?

Setting the Project build tools in your Project Options is insufficient to convert a project into a package. If the .Rproj file has the package development fields (i.e., Project build tools to Package) but the mandatory fields are missing from the DESCRIPTION file, the Build pane will be triggered:

(a) DESCRIPTION
Figure C.2: Unchanged DESCRIPTION file after changing .Rproj

But trying to load the code in the R/ folder with Build > Load All (or devtools::load_all()) we return the following error:

install.packages("devtools")
library(devtools)
devtools::load_all()
(a) Build pane tools
Figure C.3: Attempt to load_all() code in R/ folder

The directory must include a DESCRIPTION file containing the mandatory fields and an .Rproj file with the package configuration fields listed above to be a functional R package.

Read more about DESCRIPTION file fields in R Packages, 2ed

RStudio project files

You can read more about the benefits of using RStudio projects to configuring project-level options here.

C.4 I have the mandatory fields in my .Rproj file and DESCRIPTION, but still no Build pane?

To get the IDE to re-read the .Rproj file, you might have to terminate the session (Session > Terminate R… > Yes)

(a) Session > Terminate
(b) Click Yes
Figure C.4: Terminate your R session

This prompts the IDE to re-read the .Rproj file and trigger the Build pane.