Chapter 7 Dependencies
Dependencies = other R packages.
There are (mostly) three types:
- Depends
- Imports
- Suggests
Enhances
is used rarely
7.1 Adding dependencies
- Add an entry in the
DESCRIPTION
file - Add a declaration of what you are importing from the package:
- all of the package, or (
@import package
) - certain functions (
@importFrom package function
) - there’s no standard for where to do this.
- i like to do in a package named manual file (e.g.,
foobar-package.R
) so you can keep track of all imports in one place - but some like to list imports in each file/function where they are used
- i like to do in a package named manual file (e.g.,
- all of the package, or (
You can do this manually or via usethis::use_package('package_name')
7.2 Add a dependency to a package
7.2.1 Exercise
Choose a package that’s easy for you to work with.
Add it to your package
Reinstall and load your package
Does it work?