datacamp-logo

Depends or imports?

The Depends and Imports fields in the DESCRIPTION file can cause a lot of confusion to those new to package building! Both of these fields contain package dependencies which are installed when you install the package. However, the difference between them is that the packages listed in depends are attached when the package is loaded, whereas the packages listed in imports are not.

This distinction is important because if two different packages have an identically named function, the version of the function from the package which has been loaded most recently will be used. Therefore, to make sure you are using the correct function, it is best practice to use imports to list your dependencies and then in your code explicitly name the package and function it's from in the form package::function(), e.g. dplyr::select().

In the majority of cases, you should only list the version of R required in the Depends field and the package in the Imports field.

Which of the following should you add to the Imports field in your description file for the datasummary package?

Answer the question
50 XP
Possible Answers
  • press
  • press
  • press
  • press