Skip to Content
R Packages, 2nd Edition
book

R Packages, 2nd Edition

by Hadley Wickham, Jennifer Bryan
June 2023
Intermediate to advanced content levelIntermediate to advanced
381 pages
9h 2m
English
O'Reilly Media, Inc.
Content preview from R Packages, 2nd Edition

Chapter 10. Dependencies: Mindset and Background

You take a dependency when your package uses functionality from another package (or other external tool). In “Imports, Suggests, and Friends”, we explained how to declare a dependency on another package by listing it in DESCRIPTION, usually in Imports or Suggests. But that still leaves many issues for you to think about:

  • When should you take a dependency? What are the risks and rewards? In “When Should You Take a Dependency?” we provide a framework for deciding whether a dependency is worth it. This chapter also includes specific sections for deciding between Imports and Suggests (see “Whether to Import or Suggest”) and between Imports and Depends (see “Whether to Import or Depend”).

  • How should you use different kinds of dependencies in different contexts? That is, imported versus suggested packages, used inside your functions versus tests versus documentation. We have to defer this to the next chapter (Chapter 11), because the justification for those recommendations relies on some additional technical background that we develop here.

A key concept for understanding how packages are meant to work together is that of a namespace (see “Namespace”). Although it can be a bit confusing, R’s namespace system is vital for the package ecosystem. It is what ensures that other packages won’t interfere with your code, that your code won’t interfere with other packages, and that your package works regardless of the environment in which ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

R Packages

R Packages

Hadley Wickham
R Cookbook, 2nd Edition

R Cookbook, 2nd Edition

JD Long, Paul Teetor
Advanced R

Advanced R

Hadley Wickham

Publisher Resources

ISBN: 9781098134938Errata Page