Package Dependencies

Guide R package dependency management across DESCRIPTION file sections.

Updated Feb 15, 2026
One-click install
npx skills add https://github.com/choxos/RPkgAgent --skill package-dependencies
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: Package Dependencies
Source: https://github.com/choxos/RPkgAgent/tree/main/plugins/r-package-development/skills/dependencies
Command: npx skills add https://github.com/choxos/RPkgAgent --skill package-dependencies

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill provides a comprehensive guide to understanding and managing dependencies in R packages, ensuring robust and maintainable code.

Core Features & Use Cases

  • Dependency Types: Clearly distinguishes between Imports, Suggests, Depends, LinkingTo, and Config/Needs/*.
  • Usage Patterns: Demonstrates correct ways to use dependencies in package code, tests, examples, and vignettes.
  • Use Case: You're building an R package and are unsure whether to list ggplot2 in Imports or Suggests. This Skill will guide you through the decision-making process and show you how to correctly implement it.

Quick Start

Learn how to correctly add and use R package dependencies by reading the guide.

Frequently Asked Questions about Package Dependencies

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I manage R package dependencies in the DESCRIPTION file?

Manage R package dependencies by correctly listing them under Imports, Suggests, Depends, LinkingTo, or Config/Needs/* sections in the DESCRIPTION file. This ensures robust code by defining exactly how packages interact with your code, tests, and vignettes.

When should I use Imports vs Suggests for an R package dependency?

Use Imports for packages strictly required for your R package to function, utilizing explicit namespace calls or @importFrom directives. Use Suggests for optional dependencies, implementing conditional checks and skip patterns in tests or vignettes when the dependency is absent.

How do I avoid circular dependencies when building R packages?

Avoid circular dependencies in R packages by carefully structuring your DESCRIPTION file dependency types and utilizing explicit namespace usage. Properly segregating mandatory packages in Imports from optional ones in Suggests prevents recursive loading loops.

What is the correct way to use roxygen2 directives for R package imports?

Use roxygen2 directives like @importFrom to explicitly import specific functions from another package's namespace into your R package. This approach keeps your namespace clean and avoids conflicts compared to importing an entire package.

How do I write conditional checks for suggested R packages in tests and vignettes?

Write conditional checks for suggested R packages using `requireNamespace()` to verify availability before execution. In tests, apply skip patterns if the dependency is missing, allowing your R package to gracefully handle optional functionality without failing.

Does R package dependency management require explicit version specification?

Yes, R package dependency management supports explicit version specification in the DESCRIPTION file. Specifying minimum versions for dependencies like Imports or Suggests ensures your package uses compatible API features and prevents unexpected errors from older versions.