Cette page est affichée en anglais. Une traduction française est en cours.
ConfigsJul 28, 2026·3 min de lecture

devtools — Tools to Make R Package Development Easier

devtools is an R package that streamlines the entire R package development workflow. It provides functions for loading, testing, documenting, checking, and installing packages from local directories, GitHub, and other sources.

Prêt pour agents

Installation agent prête

Cet actif peut être installé après choix du runtime, vérification du plan et exécution de la commande adaptée.

Native · 98/100Policy : autoriser
Surface agent
Tout agent MCP/CLI
Type
Skill
Installation
Single
Confiance
Confiance : Established
Point d'entrée
devtools Guide
Commande d'installation directe
npx -y tokrepo@latest install 95b956f4-8ac7-11f1-9bc6-00163e2b0d79 --target codex

À exécuter après confirmation du plan en dry-run.

Introduction

devtools is an R package by Hadley Wickham and the r-lib team that removes the friction from R package development. Before devtools, building and testing packages required manual command-line invocations and configuration. devtools wraps these steps into simple R functions that work from an interactive R session or RStudio, making the edit-load-test cycle fast and natural.

What devtools Does

  • Loads package source code into the current session with load_all() for rapid iteration without reinstalling
  • Runs testthat test suites with test() and reports results inline
  • Generates documentation from roxygen2 comments with document()
  • Runs the full R CMD check suite with check() to catch issues before CRAN submission
  • Installs packages from GitHub, GitLab, Bitbucket, and URLs with install_github() and friends

Architecture Overview

devtools acts as a thin wrapper around a suite of focused packages: pkgload (for load_all()), pkgbuild (for building tarballs), rcmdcheck (for check()), remotes (for installing from remote sources), roxygen2 (for documentation), and testthat (for testing). This modular design means each component can be updated independently. devtools re-exports the key functions from these packages so developers only need to load one package.

Self-Hosting & Configuration

  • Install from CRAN: install.packages("devtools")
  • Create a new package skeleton with usethis::create_package("mypackage")
  • Add tests with usethis::use_testthat() and write test files in tests/testthat/
  • Configure CI with usethis::use_github_action_check_standard() for automated R CMD check
  • Set DESCRIPTION fields (Imports, Suggests, License) and use usethis::use_package() to add dependencies

Key Features

  • load_all() simulates package installation by sourcing all R files and loading compiled code, enabling a fast development loop
  • install_github("owner/repo") installs packages directly from GitHub without manual download
  • check() catches common issues (missing docs, broken examples, test failures) before CRAN submission
  • Tight integration with usethis for scaffolding package infrastructure (tests, CI, badges, NEWS, vignettes)
  • Works in both interactive R sessions and RStudio with dedicated build pane support

Comparison with Similar Tools

  • usethis (R) — complementary package for one-time setup tasks (creating files, configuring CI); devtools covers the iterative development cycle
  • pak (R) — faster package installer; devtools focuses on development workflow, not just installation
  • remotes (R) — handles remote installation only; devtools provides the full develop-test-check-install workflow
  • setuptools / pip (Python) — Python packaging tools; devtools is the R equivalent but more opinionated and integrated
  • npm / cargo — language-specific package managers; devtools is unique in combining development workflow with package management

FAQ

Q: Do I need devtools to develop R packages? A: Not strictly, but it makes the process much simpler. Without it, you would use R CMD commands from the terminal.

Q: What is the difference between devtools and usethis? A: usethis handles one-time setup (create files, configure settings). devtools handles repeated actions (load, test, check, install). They work together.

Q: Can I install packages from private GitHub repos? A: Yes. Set a GITHUB_PAT environment variable with a personal access token and use install_github("owner/private-repo").

Q: Does devtools work outside of RStudio? A: Yes. All devtools functions work in any R console, terminal, or IDE. RStudio provides additional UI integration but is not required.

Sources

Fil de discussion

Connectez-vous pour rejoindre la discussion.
Aucun commentaire pour l'instant. Soyez le premier à partager votre avis.

Actifs similaires