Congatulations, your function appears to be working. Now is a good time to run the devtools::check
pipeline. This performs a number of checks on the code and documentation to ensure the package is setup and functioning correctly. Once you have written unit tests, they will also be run by check
devtools::check()
After a number of checks, this initial check fails with:
❯ checking package dependencies ... ERROR
Namespace dependencies missing from DESCRIPTION Imports/Depends entries:
'cli', 'dsBase'
See section ‘The DESCRIPTION file’ in the ‘Writing R Extensions’
manual.
1 error ✖ | 0 warnings ✔ | 0 notes ✔
This is telling us that we are using two external packages within our package (dsBase
and cli
), however these have not been specified in the DESCRIPTION file. We can add them by adding the following line to the DESCRIPTION file:
Imports:
cli,
dsBase
Imports
and Suggests
are both areas of the DESCRIPTION file to add dependencies to other packages. Packages which are used within the functions you write and thus necessary for these to run correctly should be placed within imports
. Packages that you use in your package but are not essential to the user (e.g. packages you use in yours tests) should be placed in suggests
.
We can now run the check again:
devtools::check()
And this time we can see that there are no errors:
── R CMD check results ────────────────────────── dsExample 0.0.0.9000 ────
Duration: 23.9s
0 errors ✔ | 0 warnings ✔ | 0 notes ✔