The current introduction to my package development workshops

[This article was first published on Maëlle's R blog on Maëlle Salmon's personal website, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

I somewhat regularly teach about package development. One recent example was a workshop for rOpenSci champions. I am improving my teaching over time (thankfully 😅) but one thing I have down by now is the intro, which is mostly my throwing together my favorite quotes about R package development! Let me write it up.

Where I explain why people shouldn’t flee the workshop

After boasting a bit (a.k.a. sharing my package development creds to introduce myself), I answer three retorical questions:

Why develop an R package?

Developing an R package is the easiest way to share code/data/R Markdown templates… with

  • (future) you: a package for organizing your utility functions in a smart way;

  • the collaborators you know: a package for your team;

  • and the collaborators you don’t: a package for the whole wide world. Without needing to be a generalist tool à la ggplot2, your package could help other R users!

Why learn about package development?

This is a different question! I love Jon Calder’s wording about this. You should learn about package development

“- To share code (and data)”;

Which is learning about package development to develop your packages.

“- To leverage existing tooling”;

Which could be learning about package development for using part of the infrastructure, like the one for testing, in your own projects.

“- To contribute to other packages”.

Which is learning about package development to improve packages owned by other people (in my words, being a package aunt/babysitter).

So you don’t need to even have an idea or need for your own R package for that learning to be relevant.

Who can learn about package development?

To answer this question I use the wise words of Susan Johnston.

“- Can you open R or RStudio?”

“- Can you install a package?”

“- Have you ever written a function in R?”

“- Could you learn how to write a function in R?”

“➡️ You can write a package in R!”

Side-note: where to learn about functions

Knowing vaguely what a function is a pre-requisite when I teach package development (the example functions I use are nothing fancy) but I’ve collated links for those who want to learn:

Where I go more into details about packages

What is a package?

The author of this excellent quote (first reproduced in French) is Sébastien Rochette:

“Pour réduire ses craintes, il faut se dire que ce n’est ni plus ni moins qu’un dossier organisé d’une manière contrainte.”

“To be less afraid you have to tell yourself that it’s simply a folder organized in a constrained way.”

At this point what could remain scary is, how do I remember about these constraints and rules? So here comes…

Automation!

At this point I introduce usethis as an “actually useful Clippy”.

I don’t necessarily use, but think of, this great quote of Jenny Bryan’s:

“The usethis package implements this important principle: Automate that which can be automated. Your computer was literally born to implement rote-but-fussy stuff for you.”

Why automate?

Even in the intro I like to underline that automating package development tasks is useful not only for the regular work of package development, but also for teaching (😉) and for reproducing problems.

Goals of a beginner workshop

At least the latest one I taught had two goals:

  • For the learners to get to know the tools for package development that I use myself;

  • For the learners to learn that there is no magic, only practice and ✨ tips ✨.

Conclusion

In this post I wrote up the intro that I’ve now used a few times for my package development teaching. If you’re curious, to conclude such workshops I list what I think is actually difficult: writing good code, writing a good interface, writing good docs. But even that can be learnt (still learning myself 💪). In my teaching materials I share a list of resources.

To leave a comment for the author, please follow the link and comment on their blog: Maëlle's R blog on Maëlle Salmon's personal website.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)