Unveiling the Ultimate "R Package Developer Master Resource List"
Creating robust and professional R packages can be a tedious process, this post aids to provide tools for R Package developers.
Overview
This article aims to provide an exhaustive list of helpful tools, packages, and resources for developers, authors, maintainers, reviewers, and stakeholders in the R Package development workflow.
Welcome to the world of R Package Development! Whether you're a seasoned R programmer looking to expand your toolkit or a newcomer eager to dive into the exciting realm of package development, you've come to the right place. In this comprehensive guide, we'll unveil the essential resources every R package developer needs to master their craft. From tutorials and books to online communities and tools, we've curated a treasure trove of resources to help you embark on your journey towards becoming a proficient R package developer.
Throughout this article, I will provide a walkthrough of the various packages, tools, resources, and axioms I have encountered over my years as an R package software engineer.
R User vs. R Developer
In the world of R programming, there are distinct roles and distinctions between an R User and an R Developer, each with its own set of responsibilities, skills, and objectives.
To distinguish, R developers develop new innovative solutions while R Users use the tools and packages that the developers created. This article is aimed towards the development side of the spectrum and attempts to provide a comprehensive, curated toolbox for the R Developer, specifically in regard to developing R Packages.
In summary, while both R users and R developers utilize R for data analysis and statistical computing, they differ in their focus and expertise. R users primarily leverage R for data analysis tasks, while R developers specialize in creating and maintaining R packages to enhance the functionality and capabilities of the R programming language for a broader audience of users.
R Users
Definition: An R user is someone who primarily utilizes R for data analysis, statistical modeling, visualization, and other tasks related to data science, research, or analytics.
Skills & Responsibilities:
- Proficient in using R for data manipulation, exploration, and analysis.
- Familiarity with statistical methods and techniques for interpreting data.
- Ability to create visualizations and plots to communicate insights effectively.
- Understanding of data structures, functions, and packages within R.
- May use R for tasks such as data cleaning, hypothesis testing, regression analysis, and machine learning
Objectives:
- Analyze and interpret data to derive meaningful insights and make data-driven decisions.
- Communicate findings through reports, presentations, or visualizations.
- Utilize R packages and libraries to streamline analysis workflows and enhance productivity.
- Collaborate with colleagues or stakeholders to address specific analytical needs or research questions.
R Developer
Definition: An R developer is someone who focuses on creating, maintaining, and extending R packages, libraries, and tools for the broader R community.
Skills and Responsibilities:
- Proficiency in programming with R, including knowledge of object-oriented programming principles, functions, and package development.
- Understanding of software engineering practices such as version control, testing, and documentation.
- Ability to design, implement, and maintain R packages to address specific needs or solve particular problems.
- Familiarity with R package development tools such as
devtools
,roxygen2
, andtestthat
. - Contribution to the R ecosystem through the creation of new packages, improvement of existing packages, or participation in community discussions and collaborations.
Objectives:
- Develop and release high-quality R packages that provide valuable functionality to users across different domains.
- Ensure the reliability, efficiency, and usability of R packages through rigorous testing, documentation, and code review.
- Engage with the R community to gather feedback, address issues, and collaborate on package development efforts.
- Stay updated on emerging trends, best practices, and advancements in R programming and package development.
Getting Started
Now that you understand the difference between an R User ans R Developer, a question arises: "How can one go from being a user to a developer?".
The answer is simple, create something! In this case, create an R Package.
Once you have accumulates more than 2-3 common functions that operate within the same context, that is a primary indicator that you should structure your project as an R Package.
After you have more than one function it starts to get easy to lose track of what your functions do. Similarly, it can start to become difficult to track down, name, and organize the functions and you may be tempted to put all of the functions in one file and just source it. Instead, I propose the best solution is to create an R package.
What you Need
To begin creating an R Package, you need:
- R and RStudio installed on your machine
- Git and GitHub
- Some initial R functions
- R Development Packages:
devtools
usethis
roxygen2
pak
knitr
andrmarkdown
From there you can continue to naming your package, scaffolding out its structure, adding functions, documentation, metadata, data, license, vignettes, etc.
Pre-Requisite Resources
To start, R package developers need to be familiar with the fundamentals of package development, and therefore should be familiar with some of the highest regarded resources available to read.
Anyone who is serious about developing production grade R packages needs to be familiar with most of, if not all of the following resources and guides:
Table 1: R Package Developer Essentials
Resource | Source |
Writing R Extensions | CRAN Manuals |
R Packages | Hadley Wickham |
R Package Primer | Karl Broman |
Package Guidelines | Bioconductor |
rOpenSci Packages Developer Guide | rOpenSci |
View Citations:
(Wickham and Bryan, n.d.a, n.d.b; “Why Package and Environment Management Is Critical for Serious Data Science,” n.d.a, n.d.b; Vidoni, n.d.; Initiative, n.d.; “An Introduction to Packager,” n.d.; Gandrud 2015; Glennie 2020; “Owen-TheRGuide.pdf,” n.d.; Riederer, n.d.; Spector 2004; Team, n.d.; Zhu and Jianan, n.d.)
Writing R Extensions Manual
The Writing R Extensions Manual is perhaps the most crucial resource listed above, and has even been considered the Bible of R Package Development.
As Hadley puts it in his book Writing R Packages:
"The best resource for the official details of package development is always the official writing R extensions manual. However, this manual can be hard to understand if you’re not already familiar with the basics of packages. It’s also exhaustive, covering every possible package component, rather than focusing on the most common and useful components, as this book does. Writing R extensions is a useful resource once you’ve mastered the basics and want to learn what’s going on under the hood.”
— Hadley Wickham
Thanks to Colin Fay, a more elegant version of the original manual has been created as a bookdown site and published online at https://colinfay.me/writing-r-extensions.
Note: The other manuals listed on the CRAN Manuals website contain a lot of hidden gems that are often overlooked by R developers. These resources contain some of the most crucial, foundational knowledge that anyone using R should eventually be made aware of, therefore I highly recommend you check those out in addition to Writing R Extensions.
R Packages Book
The "R Packages" (2nd Edition) Book outlines the importance of packages in R as the fundamental unit of shareable code, combining code, data, documentation, and tests.
It highlights the vast array of over 19,000 packages on CRAN and encourages readers to develop their own packages for easier code sharing and organization. The book aims to automate package development as much as possible, utilizing the devtools
and usethis
packages and the RStudio IDE for a more efficient workflow.
For a detailed overview, visit the introduction page.
R Package Primer
The "R package primer" provides a minimal tutorial on creating R packages, emphasizing their simplicity and utility for code distribution and personal organization. The primer covers essential topics like package creation, documentation, and checking, alongside advanced topics like GitHub integration, CRAN submission, and writing vignettes. It advocates for package development as a practice for better code management and documentation, even for personal use. For more detailed guidance, visit Karl Broman's R package primer.
Bioconductor Package Guidelines
The "Bioconductor Packages: Development, Maintenance, and Peer Review" guide offers comprehensive insights into the creation, upkeep, and review process of Bioconductor packages. Authored by Kevin Rue-Albrecht, Daniela Cassol, Johannes Rainer, and Lori Shepherd, it serves as an essential resource for developers within the Bioconductor project, promoting high-quality, well-documented, and interoperable software. Contributions to the guide are welcome via GitHub, indicating a collaborative and open-source approach to improving package development practices. For more details, visit the Bioconductor contributions guide.
rOpenSci Packages Development Primer
The "rOpenSci Packages: Development, Maintenance, and Peer Review" guide is a comprehensive resource designed for developers involved in the rOpenSci project. It covers a wide range of topics from package development, continuous integration, security best practices, to the software peer review process. It also includes guidance on package maintenance, collaboration, and marketing. Authored by the rOpenSci software review editorial team, it is an essential read for anyone looking to contribute to the rOpenSci ecosystem. For detailed information, visit the rOpenSci Development Guide.
R Packages
Next, I will provide a comprehensive list of R Packages that aim to assist the development process.
Essentials
The following packages represent Core Development Libraries and should generally be utilized in all scenarios of package development.
Devtools and Usethis
For automating the development workflow:
devtools
- Thedevtools
package is a fundamental tool for R package development, providing functions for package creation, documentation, testing, and deployment. It streamlines the development process by automating common tasks like building, checking, and installing packages, making it an indispensable tool for R developers.usethis
- Theusethis
package offers a collection of functions for automating package development workflows, including project setup, file creation, and version control integration. It simplifies common tasks like creating package directories, adding functions, and managing dependencies, enhancing productivity and efficiency for R developers.
Documentation
For generating manual pages and documentation:
roxygen2
- Theroxygen2
package simplifies the process of documenting R code by generating Roxygen-style comments from function definitions. It enables developers to create consistent, well-formatted documentation for their packages, enhancing readability and maintainability. By automating the documentation process,roxygen2
ensures that package documentation stays up-to-date with code changes, facilitating collaboration and code sharing.knitr
&rmarkdown
- Theknitr
andrmarkdown
packages provide tools for creating dynamic reports, presentations, and documentation in R. They enable developers to embed R code, plots, and text in a single document, facilitating reproducible research and effective communication of results. By combining code and narrative in a single document,knitr
andrmarkdown
enhance the clarity and transparency of package documentation, making it easier for users to understand and utilize the package.
Testing
For testing:
testthat
- Thetestthat
package is a unit testing framework for R that enables developers to write and run tests for their code. It provides functions for defining test cases, running tests, and reporting results, ensuring that packages behave as expected across different scenarios. By incorporating test-driven development practices,testthat
helps developers identify and fix bugs early in the development process, improving code quality and reliability.tinytest
- Thetinytest
package is a lightweight testing framework for R that simplifies the process of writing and running tests. It offers a simple and intuitive interface for defining test cases, running tests, and reporting results, making it easy for developers to validate their code and ensure its correctness. By providing a minimalistic testing solution,tinytest
streamlines the testing process and enhances the quality and robustness of R packages.shinytest2
- Theshinytest2
package is a testing framework for Shiny applications that enables developers to automate the testing of interactive web applications. It provides functions for recording and replaying user interactions, capturing screenshots, and comparing outputs, ensuring that Shiny apps behave as expected across different environments. By automating the testing process,shinytest2
helps developers identify and fix issues in their Shiny apps, improving user experience and reliability.
Dependency Management
For managing package dependencies:
pak
- Thepak
package is a lightweight dependency management tool for R that simplifies the installation and management of package dependencies. It provides functions for installing, updating, and removing packages, ensuring that packages are installed from reliable sources and compatible with the current R environment. By automating dependency management tasks,pak
streamlines the package development process, reducing the risk of conflicts and errors.remotes
- Theremotes
package offers functions for installing packages from remote repositories like GitHub, GitLab, and Bitbucket. It enables developers to install packages directly from source control repositories, facilitating collaboration and sharing of packages across different platforms. By providing a flexible and extensible interface for package installation,remotes
enhances the accessibility and availability of R packages for developers and users.renv
- Therenv
package is a dependency management tool for R that creates isolated project environments with specific package versions. It enables developers to capture and manage package dependencies within a project, ensuring reproducibility and consistency across different environments. By creating project-specific package libraries,renv
helps developers avoid conflicts and ensure that packages are installed and loaded correctly, enhancing the reliability and portability of R projects.
Useful Common Libraries
available
- Check if a package is available on CRANlifecycle
- represent package and function development lifecycle stagesdesc
- Manage and edit the package'sDESCRIPTION
pkgdown
- Generate package documentation static sitetestdown
- Generate test reportsgitdown
- Generate git commit messages
Roxygen Tools
roxygen2md
roxyglobals
rd2list
Rd2roxygen
rd2markdown
roxygen2comment
Dependency Tools
attachment
- Attach and detach packagesautomagic
- Automatically install and load packagesCodeDepends
- Identify dependencies between functionsdep
- Dependency managementsysreqs
- Identify system requirements for R packagespkgnet
- Visualize package dependenciesfunctiondepends
- Identify dependencies between functions
Git and GitHub
gert
- Git toolsgitdown
- Generate git reportsgit2r
- Git interfacegh
- GitHub interfacegit4r
- Git interfacegitGPT
- Git interface with GPT-3precommit
- Pre-commit hooks
Configuration
config
- Configuration managementoptions
- Set and get options
Credentials & Secrets
keyring
- Securely store and retrieve credentialscredentials
- Securely store and retrieve credentialsgitcreds
- Securely store and retrieve git credentialsssh
- SSH interfaceaskpass
- Prompt for passwords
plus, base R's Sys.genenv()
and Sys.setenv()
.
Fundamental Low-Level Packages
These packages are not necessarily called directly but are built on top of as dependencies to higher level libraries (i.e.
usethis
,devtools
, etc.)
pkgload
- Load packagespkgbuild
- Build packagespkgdepends
- Manage package dependenciespkgapi
- Manage package APIpkgcache
- Manage package cachepkgnet
- Visualize package dependencies
Linting & Styling
goodpractice
- Check package qualitylintr
- Lint R codestyler
- Style R codeformatR
- Format R codestylermd
- Style R Markdownspelling
- Spell check R coderoxylint
- Lint Roxygen commentscleanr
- Clean R codejanitor
- Clean R Dataframesanitizers
- Sanitize R coderefactor
- Refactor R code
Package Documentation
docthis
- Document R objectsprettydoc
- Custom RMardown templatesquarto
- New RMarkdown'ish packagepkgdown
- Generate package documentationtestdown
- Generate test reportsautodoc
- Automatically document R objectspapillon
- Create internal functions for launching documentationfusen
- RMarkdown driven package developmentbadger
- Generate badges for R packagesbadgen
- Generate badges for R packagesbookdown
- Generate books from RMarkdownbookdownplus
- Generate books from RMarkdownaltdoc
- Generate alternative documentationfledge
- AutomateNEWS.md
newsmd
- AutomateNEWS.md
autonewsmd
- AutomateNEWS.md
docreview
- Review documentationcovrpage
- Generate coverage reports
Metadata
codemeta
- Generate CodeMeta metadatacodemetar
- Generate CodeMeta metadatapkgstats
- Generate package statisticssessioninfo
- Generate session information
Checks & Tests
rcmdcheck
-R CMD CHECK
runnertestdat
- Generate test datavalidate
- Validation and Data Qualityrealtest
- Real world testingroxytest
- Test Roxygen commentscheckhelper
- Helper functions forR CMD CHECK
codetools
- Code analysis toolscheckglobals
- Check global variablesrhub
- Check R packages on various platforms
Validation and Assertions
assertthat
- Assertionscheckmate
- Assertionsassertive
- Assertionsassertthat
- Assertionsassert
- Assertionspointblank
- Validation
Utilities
fs
- File system interfacepurrr
- Functional programmingdplyr
- Data manipulationtidyr
- Data manipulationstringr
- String manipulationlubridate
- Date manipulationDBI
- Database interfacedbx
- Database interfaceRPostgres
- DBI compliant interface for PostgreSQLdbplyr
- Database interface withdplyr
connections
- Database connectionspool
- Database connection poolingdm
- Data Modelingdatamodelr
- Data Modelingplumber
- API developmentcli
- Command line interfacelogger
- Loggingsnakecase
- Convert snake caseprefixer
- Add prefixes to functionsaddinit
- Add script headersshiny
- Shiny appshtmltools
- HTML toolsshinyjs
- Shiny JavaScriptgolem
- Shiny app developmentpacker
- Package JavaScript with R coderoger
- R Markdown driven package developmentpatrick
- Automate package developmentcachem
- Cachingmemoise
- Cachingqs
- Quick serialization for cachingdigest
- HashingR6
- Object oriented programmingcranlogs
- CRAN download logsdlstats
- CRAN download logsoysteR
- RStudio addinfoghorn
- RStudio addinactions
- GitHub actionsrworkflows
- R Workflowstic
- timingtictoc
- timinggpg
- GPG interfacedebugr
- Debuggingvaltools
- Validation toolspkgcond
- Package conditionsriskmetric
- Risk metricsreprestools
- Reproducible research toolscontainerit
- Containerize R codedockerfiler
- Dockerfile generator
onetime
- One time code executiongitignore
- Generate.gitignore
files
whoami
- User informationrprojroot
- Project roothere
- Project rootwhisker
- Templatingmagick
- Image processingwaldo
- Low-Level R Objectsvctrs
- Vector manipulationconflicted
- Conflict resolutionwebfakes
- Web scrapingps
- Process managementprocessx
- Process managementcallr
- Process managementwithr
- Process managementevaluate
- Evaluate R codesystemfonts
- System fontslater
- Futurefuture
- Futurepromises
- Promisepillar
- Tidy printingpretyunits
- Pretty unitsprogress
- Progress bars
bench
- Benchmarkingprofvis
- Profilingymlthis
- YAMLpiggyback
- Data sharingitdepends
- Dependency managementdependencies
- Dependency managementellipsis
- Ellipsis (...
)miniUI
- Shiny UIrversions
- R versionspingr
- Ping URLsrcompendium
- Research Compendiumlitr
- Literate programmingleprechaun
pkgverse
metamakr
Summary
Understanding the Basics: Before delving into the intricacies of package development, it's crucial to grasp the fundamental concepts of R programming. Resources like "R for Data Science" by Hadley Wickham and Garrett Grolemund serve as an excellent starting point for beginners, providing a comprehensive overview of R programming essentials and data manipulation techniques.
Mastering Package Development: Once you've familiarized yourself with the basics, it's time to dive into the world of package development. The "R Packages" book by Hadley Wickham is the go-to resource for understanding the principles of package structure, documentation, and best practices. Additionally, online tutorials from platforms like DataCamp and RStudio provide hands-on guidance for creating your first R package from scratch.
Harnessing the Power of Version Control: Effective version control is essential for managing the development and collaboration of R packages. Platforms like GitHub offer robust version control capabilities, allowing developers to track changes, collaborate with peers, and maintain a history of their package development journey. Resources such as "Happy Git and GitHub for the useR" by Jenny Bryan provide comprehensive guides to mastering Git and GitHub workflows tailored specifically for R users.
Engaging with the Community: The R community is a vibrant ecosystem bustling with passionate developers, users, and enthusiasts. Engaging with online communities such as Stack Overflow, RStudio Community, and the R4DS Slack channel enables you to seek guidance, share insights, and collaborate with fellow developers. Conferences like useR! and rstudio::conf provide opportunities to connect with experts, attend workshops, and stay updated on the latest trends in R package development.
Streamlining Development with Tools and Packages: As you progress on your journey, leveraging tools and packages designed for R package development can significantly enhance your productivity and efficiency. Tools like devtools, roxygen2, and testthat streamline package development tasks such as building, documenting, and testing your code. Additionally, exploring specialized packages like usethis and pkgdown empowers you to automate common development workflows and create polished package documentation and websites with ease.