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:
- Materials from Stephanie Kirmerâs R-Ladies East Lansing tutorial
- Write your own R functions, stat 545 course by Jenny Bryan and The STAT 545 TAs;
- Chapter about functions in the book âR for Data Scienceâ by Hadley Wickham, Mine Ăetinkaya-Rundel, and Garrett Grolemund;
- Fun with Functions talk by Kaylea Haynes, R-Ladies Manchester.
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.
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.