Maëlle Salmon (rOpenSci)
Construction blocks

https://stats-devguide.ropensci.org/
Before: Several Markdown files.
Today: A whole book, multilingual now! Plus the stat dev guide.
Jenga wooden blocks
What does this mean?
If you use software that lacks automated tests, you are the tests.
Jenny Bryan, Twitter.
What is testing?
Sisyphus pushing a rock on a mountain
Crane carrying a rock over a mountain
All packages should have a test suite that covers major functionality of the package. The tests should also cover the behavior of the package in case of errors.
Using the testthat package
📸
An atomic habit 💪
Using continuous integration ☁️
Your tests run on the cloud every time you make a change!
usethis::use_github_action("check-standard")
It is good practice to write unit tests for all functions, and all package code in general, ensuring key functionality is covered. Test coverage below 75% will likely require additional tests or explanation before being sent for review.
No test, no coverage.

expect_that(cool_function(2), 4)
expect_type(cool_function(2), "numeric")
expect_that(cool_function(2), 4)
expect_error(cool_function("a"), class = "uncool")
✨ {covr} ✨
Tests should be easy to understand, and as self-contained as possible. When using testthat, avoid using code outside of test_that() blocks (such as pre-processing steps). We recommend reading the high-level principles for testing in the R Packages book.
(“R Packages” by Hadley Wickham and Jenny Bryan)
library(dplyr)
dat <- data.frame(a = 1:3, b = c("a", "b", "c"))
skip_if_not_installed("a_package")
test_that("my_fun() does this", {
expect_equal(my_fun(dat), ...)
})
dat2 <- data.frame(x = 1:5, y = 6:10)
skip_on_os("windows")
test_that("my_fun_2() does that", {
dat2 <- mutate(dat2, z = x + y)
expect_equal(my_fun_2(dat, dat2), ...)
})test_that("my_fun() does this", {
skip_if_not_installed("a_package")
dat <- data.frame(a = 1:3, b = c("a", "b", "c"))
expect_equal(my_fun(dat), ...)
})
test_that("my_fun_2() does that", {
skip_if_not_installed("a_package")
skip_on_os("windows")
dat <- data.frame(a = 1:3, b = c("a", "b", "c"))
dat2 <- data.frame(x = 1:5, y = 6:10)
dat2 <- dplyr::mutate(dat2, z = x + y)
expect_equal(my_fun_2(dat, dat2), ...)
})Key for
Your one-stop! 😎
Colorful Stack Toy on Blue Background
But only when applied!
https://ropensci.org/software-review
Improve quality of packages in scope
Build a community of practice
automation! {pkgcheck}
reviewers’ expertise and outside perspective
You can participate!
Submit packages;
Volunteer as a reviewer.
Guidelines like ours.
Review process somewhere. ChatOps?
End goal: registering the package.
https://intro-programacion.netlify.app/d_checklist by Paola Corrales & Yanina Bellini Saibene
https://github.com/paocorrales/jtp by Paola Corrales
Check packages by students,
Using pkgcheck (+ rcmdcheck + covr),
Posting the report in a GitHub issue. https://github.com/LucaGiu204/meteoR/issues/4
✨ R-universe package manifest ✨
https://ropensci.org/r-universe
A way to publish R packages
A way to discover R packages
Develop packages on any public Git platform
Install R-universe’s GitHub App
Create packages.json
packages.jsonGuidelines like ours.
Review process somewhere.
End goal: registering the package within your R-universe.
Pastel pink construction blocks
““Community over code”. In brief, this means that the most successful long-lived projects value a broad and collaborative community over the details of the code itself.”
The Apache Way https://theapacheway.com/community-over-code/
Clarity + transparency. Clear standards, clear processes.
Kindness
rOpenSci’s community is our best asset. We aim for reviews to be open, non-adversarial, and focused on improving software quality. Be respectful and kind!
rOpenSci dev guide
The Code Review Anxiety Workbook by Carol Lee and Kristen Foster-Marks.
Decorative chick in a Basket on a Wooden Table with Eggs
Tackle maintenance tasks regularly!
Have a good codebase 😉
Foster a welcoming atmosphere for contributors. 2021 community call
Help train new contributors. rOpenSci champions program
Regularly assess your maintenance responsibilities. rOpenSci yearly package maintainer survey.

“Dependency”, Randall Munroe, xkcd.com
R-spatial evolution
The legacy R spatial infrastructure packages maptools, rgdal and rgeos were archived by CRAN on Monday, October 16, 2023.
Conferences! 😉
White and Black Checkered Brick Toys Stacked on Top of Each Other Forming Ladder
Take advantage of rOpenSci resources, examples and infrastructure!
Construction blocks
Thank you!! https://uros-maelle.netlify.app
And thanks to: Hannah Frick, Yanina Bellini Saibene.