class: center, middle, inverse, title-slide # How to improve your R package ## Automatically β¨, and not π§ ### MaΓ«lle Salmon β e-Rum 2020 ###
tiny.cc/erum2020
masalmon.eu
ma_salmon
maelle
icon0.com on Pexels
--- # Ciao! <img src="index_files/figure-html/community-1.png" width="400" /> * Work: rOpenSci, R-hub (π R Consortium) * Volunteering: rOpenSci, R-Ladies, R Weekly --- # Developing packages is great * For (future) you, * The collaborators you know, * And the collaborators you don't. <img src="img/person-holding-a-pink-ribbon-3927232.jpg" alt="Person putting a pink ribbon on a gift package" style="width:40%"> .small[Picture by [cottonbro](https://www.pexels.com/photo/person-holding-a-pink-ribbon-3927232/)] --- # Package development from 0 to hero? Easier with modern tools. Online [tutorials](https://masalmon.eu/2017/12/11/goodrpackages/#short-tutorials), [R packages book by Hadley Wickham and Jenny Bryan](https://r-pkgs.org/). ... Now what?! -- * Automatic tools & how to use them; * Making the most of information out there. Pick one or a few tip(s)! --- class: part-slide, center, bottom background-image:url(img/girl-in-green-shirt-lying-on-brown-leather-couch-4107241.jpg) # Workflow automation tools [_cottonbro on Pexels_](https://www.pexels.com/photo/girl-in-green-shirt-lying-on-brown-leather-couch-4107241/) --- # Assessing your package * [R CMD check or `devtools::check()`](http://r-pkgs.org/check.html) -- * [`BiocCheck`](https://bioconductor.org/packages/release/bioc/html/BiocCheck.html) -- * [`goodpractice`](http://mangothecat.github.io/goodpractice/) and [`lintr`](https://www.tidyverse.org/blog/2017/12/workflow-vs-script/) (possibly via [CodeFactor](https://www.codefactor.io)). -- * [`covr::package_coverage()`](http://covr.r-lib.org/reference/package_coverage.html) -- * [`devtools::spell_check()`](http://devtools.r-lib.org/reference/spell_check.html) --- # Improve metrics by hand?! Yes and no! <img src="img/yellow-latex-gloves-on-dish-rack-4039452.jpg" alt="Gloves on dish rack" style="width:30%"> .small[Picture by [Lisa Fotios](https://www.pexels.com/photo/yellow-latex-gloves-on-dish-rack-4039452/)] --- # Tools for improving -- * [`styler`](https://styler.r-lib.org/). Better paired with [version control](https://happygitwithr.com/). -- * [`roxygen2`](https://roxygen2.r-lib.org/articles/rd.html) NAMESPACE generation. Switching: [`Rd2roxygen`](https://yihui.org/rd2roxygen/). -- * [`pkgdown`](https://pkgdown.r-lib.org/). Work on reference index & navbar! -- * `usethis` e.g. [`usethis::use_test()`](https://usethis.r-lib.org/reference/index.html#section-package-development). --- # When and where to use the tools? Right after my talk (not now π), but then? <img src="img/photo-of-planner-and-writing-materials-760710.jpg" alt="Planner" style="width:60%"> .small[Picture by [Bich Tran](https://www.pexels.com/photo/photo-of-planner-and-writing-materials-760710/)] --- # Continuous integration **Run something every time you make a change** > "The idea behind continuous integration is that CI will automatically run R CMD check (along with your tests, etc.) every time you push a commit to GitHub. You don't have to remember to do this; CI automatically checks the code after every commit." [Julia Silge](https://juliasilge.com/blog/beginners-guide-to-travis/) Travis, GitHub Actions, Circle CI, [`tic` package](https://docs.ropensci.org/tic/)... --- # Continuous integration How to learn? [Julia Silge's post](https://juliasilge.com/blog/beginners-guide-to-travis/) - [Jim Hester's GitHub Actions talk](https://www.jimhester.com/talk/2020-rsc-github-actions/) - [`usethis` helpers](https://usethis.r-lib.org/reference/index.html#section-continuous-integration) -- <blockquote class="twitter-tweet"><p lang="en" dir="ltr">LIFE HACK: My go-to strategy for getting Travis builds to work is snooping on *other* people's .travis.yml files. Shoutout today to the tidyr .travis.yml for solving my problem! <a href="https://twitter.com/hashtag/rstats?src=hash&ref_src=twsrc%5Etfw">#rstats</a> π</p>— Julia Silge (@juliasilge) <a href="https://twitter.com/juliasilge/status/1205183124868681728?ref_src=twsrc%5Etfw">December 12, 2019</a></blockquote> --- # More with continuous integration Couple a thing (R CMD check? pkgdown site building?) to ... each commit, ... every Monday, ... applying a label to a pull request? --- # Pre-commit <img src="img/mara.jpg" alt="Tired: Always remember to do things well. Wired: Use continuous integration to notice wrong stuff . Inspired: Use precommit to not even commit wrong stuff" style="width:60%"> .small[Illustration by [Mara Averick](https://twitter.com/dataandme/status/1255510799273132032)] --- # Pre-commit [`precommit` R package](https://lorenzwalthert.github.io/precommit/) -- Python [precommit framework](https://pre-commit.com/) * Setup hooks * Hooks for styling, parsable R code, spell checks, etc. <img src="img/person-holding-purple-crochet-hook-and-white-yarn-3945638.jpg" alt="Purple crochet hook" style="width:50%"> .small[Picture by [Castorly Stock](https://www.pexels.com/photo/person-holding-purple-crochet-hook-and-white-yarn-3945638/)] --- # Check things before show time -- CRAN release! π Checks on different platforms, URLs, spell checks... * [submission checklist](https://cran.r-project.org/web/packages/submission_checklist.html) * [`usethis::use_release_issue()`](https://usethis.r-lib.org/reference/use_release_issue.html) creating a GitHub issue with important items. * [`devtools::release()` function](https://github.com/r-lib/devtools/blob/b166195be72927a003e6937de5c3239881095a9f/R/release.R#L39) --- # Improve workflow vs. procrastinate Risk of spending too much time on [meta-work](https://youtu.be/dIjKJjzRX_E?t=633). <img src="img/pedro-da-silva-unEmGQqdO7Q-unsplash.jpg" alt="Stop sign with photoshoped street names: 'Homework Ave' and 'Procrastination Pk'." style="width:50%"> .small[Picture by [Pedro da Silva](https://unsplash.com/photos/unEmGQqdO7Q)] --- class: part-slide, center, bottom background-image:url(img/man-in-gray-dress-shirt-sitting-on-red-leather-sofa-chair-4107239.jpg) # Reading code & about code [_cottonbro on Pexels_](https://www.pexels.com/photo/man-in-gray-dress-shirt-sitting-on-red-leather-sofa-chair-reading-book-4107239/) --- # Why read source code * You want to know what is going on. * You want to build on the function/package for your own goals. * You're just curious. * You need examples of a thing in the wild. --- # How to read source code * [`lookup` package](https://github.com/jimhester/lookup#readme) * [GitHub search](https://help.github.com/en/articles/about-searching-on-github) * Mirrors of [CRAN packages](https://github.com/cran) and [R-source](https://github.com/wch/r-source), on GitHub. <img src="img/sereja-ris-g3B53PbBfwU-unsplash.jpg" alt="Kitten looking at a laptop screen" style="width:50%"> .small[Picture by [Sereja Ris](https://unsplash.com/photos/g3B53PbBfwU)] --- # Reading code... And trying things out! Fork, clone, and explore! [Podcast episode "Learning a new codebase", with Patricia Aas](https://www.allthingsgit.com/episodes/learning_a_new_codebase_with_patricia_aas.html) <img src="img/dimitri-houtteman-93AcQpzcASE-unsplash.jpg" alt="Kitten touching a plant" style="width:40%"> .small[Picture by [Dimitri Houtteman](https://unsplash.com/photos/93AcQpzcASE)] --- # Read blogs and fora Blog posts: digested information. * [R-hub blog](https://blog.r-hub.io/), rOpenSci [blog](https://ropensci.org/blog) and [tech notes](https://ropensci.org/technotes) * [tidyverse blog](https://www.tidyverse.org/blog/2020/04/self-cleaning-test-fixtures/) * [R Weekly](https://rweekly.org/) * _Your_ blog? -- Fora: Help and learn. [R-package-devel](https://stat.ethz.ch/mailman/listinfo/r-package-devel), [RStudio community "package development" category](https://community.rstudio.com/c/package-development/11), [rOpenSci forum](https://discuss.ropensci.org/). -- π‘ Manage your subscriptions & involvement wisely! --- # rOpenSci Software Peer Review -- [Transparent, constructive, non adversarial and open review process](https://devguide.ropensci.org/softwarereviewintro.html#whatissoftwarereview) for packages [in scope](https://devguide.ropensci.org/policies.html#aims-and-scope). Interesting for authors, and reviewers! [Online book of best practice](https://devguide.ropensci.org/) for the reviews and package development. -- π Even more review and best practice on the way! [rOpenSci Statistical Software Peer Review](https://ropenscilabs.github.io/statistical-software-peer-review/) -- See also JOSS, R Journal, JSS. --- # How to improve your package Automatically β¨, and not π§
[tiny.cc/erum2020](https://maelle.github.io/erum2020/index.html#1) ποΈ R-hub resources: [Workflow automation tools for package developers (blog post)](https://blog.r-hub.io/2020/04/29/maintenance/) - [Read the R source! (blog post)](https://blog.r-hub.io/2019/05/14/read-the-source/) - [R-hub docs](https://docs.r-hub.io/). ποΈ rOpenSci resources: [rOpenSci Software Peer Review](https://ropensci.org/software-review) - [rOpenSci dev guide](https://devguide.ropensci.org/) - [rOpenSci Statistical Software Peer Review](https://ropenscilabs.github.io/statistical-software-peer-review/).