An open API service indexing awesome lists of open source software.

https://github.com/cwickham/genentech-build-tidy-tools

Materials for the Building Tidy Tools workshop at Genentech 2020
https://github.com/cwickham/genentech-build-tidy-tools

Last synced: 6 months ago
JSON representation

Materials for the Building Tidy Tools workshop at Genentech 2020

Awesome Lists containing this project

README

          

---
output: github_document
---

```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
message = FALSE
)
```

Building Tidy Tools
================

### Genentech 2020

by Charlotte Wickham and Sara Altman

## Important Links

[Sli.do](https://app.sli.do/event/71rqfi1i) for Q&A and live polls

[Google Doc](https://docs.google.com/document/d/1vahqtJ2d8zoidy1jZ19w3fxEBNWXY0YSarwtuoo-rkA/edit?usp=sharing) for reporting on your breakout room progress

[Archive of Q&A](https://docs.google.com/document/d/1PxGsv9spATRa453Q2lboDmKA1BP0odC2vw5ipWLjqe8/edit?usp=sharing) Questions and their answers from Slido

## Materials

Materials will be made available on [github](https://github.com/cwickham/genentech-build-tidy-tools).
The materials will evolve as the workshop approaches, so if you want to pre-download the materials, please wait until the day before the workshop.

However, please don't delay on [Setup][setup]. You'll want to uncover any problems in getting the required packages before our first session together.

## Setup

The most important package for Day 1 is devtools:
```{r, eval = FALSE}
install.packages("devtools")
```
If you've installed devtools before,
you should check the component packages are also up to date,
by following any instructions under the `devtools` section in the output of:
```{r, eval = FALSE}
devtools::dev_sitrep()
```


To be prepared beyond Day 1, you'll also need the following packages:
```{r, echo = FALSE, include = FALSE}
deps <- unique(sort(renv::dependencies()$Package))
deps <- setdiff(deps, c(
"ns", # created during class
"rmarkdown", "knitr", # only needed for .Rmd
"countdown", # only needed for instructor
"renv", # only needed for this block,
"gt", # only need for this README
"bizarro", # making it
c("stats", "MASS", "datasets"), # recommended
c("devtools", "roxygen2", "testthat"),
tidyverse::tidyverse_packages(),
NULL
))
install <- c(
paste0("install.packages(c(", paste0(encodeString(deps, quote = '"'), collapse = ", "), "))")
)
```
```{r code = install, eval = FALSE}
```

```r
# You may also need:
install.packages(c("ggplot2", "dplyr", "stringr"))

# And get some partial packages we'll work with later:
usethis::create_from_github("skaltman/fordogs", fork = FALSE)
usethis::create_from_github("cwickham/ns", fork = FALSE)
usethis::create_from_github("cwickham/tidytest", fork = FALSE)
```

If you're all set, you might like to download the first set of slides.

## Schedule

```{r echo = FALSE}
library(tidyverse)
day_fmt <- lubridate::stamp("Mon Sep 14th", order = "amd")
schedule <- tribble(
~ day, ~ session, ~ topic, ~ instructor,
~ notes, ~ desc,
1, 1, "Introduction / The Whole Game", "Charlotte",
"[Slides](https://github.com/cwickham/genentech-build-tidy-tools/raw/master/1-intro.pdf)",
"Build a package from scratch before your first coffee break.",
1, 2, "Testing", "Sara",
"[Slides](https://github.com/cwickham/genentech-build-tidy-tools/raw/master/2-testing.pdf)",
"Learn a testing workflow to give you confidence
your code is working as intended.",
2, 1, "Documentation / Sharing", "Sara",
"[Slides](https://github.com/cwickham/genentech-build-tidy-tools/raw/master/3-sharing.pdf)",
"Learn how to add documentation to your package,
as well as how to share you package with the world.",
2, 2, "Dependencies", "Charlotte",
"[Notes](notes/4-dependencies.Rmd)",
"Learn how to use other packages in your own packages.",
3, 1, "Using the tidyverse in packages", "Charlotte",
"[Notes](notes/5-tidyverse.Rmd)",
"Explore the challenges of including tidyverse
packages in your own packages.",
3, 2, "Interface", "Sara",
"[Notes](notes/6-interface.Rmd)",
"Learn how decisions about the name and arguments
of your functions influence how easy they are to learn
and use.",
4, 1, "Interface II", "Charlotte",
"[Notes](notes/7-interface-ii.Rmd)",
"Learn how decisions about the output
of your functions influence how easy they are to learn
and use.",
4, 2, "OO programming / S3", "Charlotte",
"[Notes](notes/8-oop.Rmd)",
"Learn how S3 objects work, and can improve
the interface of your package."
) %>%
mutate(
date = (as.Date("2020-09-14") + (day - 1)) %>% day_fmt(),
desc = glue::glue("**{topic}**\n
*{instructor}*\n
{notes}\n
{desc}")
)
schedule %>%
select(date, desc, session) %>%
pivot_wider(names_from = session, values_from = desc) %>%
gt::gt() %>%
gt::cols_label(`1` = "8:30am-10:00am", `2` = "10:30am-12:00pm",
date = "Day") %>%
gt::fmt_markdown(columns = TRUE, rows = TRUE) %>%
gt::as_raw_html()
```

The notes will be live coded and committed as we go,
so they may be empty if you are looking at them before the workshop.

You can see the scripts we'll work from in [`script/`](script/), but we recommend not reading too far ahead because you'll find answers to some of the exercises, and you'll learn more if you try to work through them first.

## Getting Help

[**Sli.do**](https://app.sli.do/event/71rqfi1i): Ask a question in the Q&A at anytime. Also vote on other peoples' questions.

**In Breakout Rooms:**

* Ask your roommates
* If your room is stuck, "Ask for help" in the [Google Doc](https://docs.google.com/document/d/1vahqtJ2d8zoidy1jZ19w3fxEBNWXY0YSarwtuoo-rkA/edit?usp=sharing)

**Zoom chat:** Reserved for urgent technical matters (e.g. "we can't hear you")

## Where to learn more

* **Workflow, devtools and usethis:**
* [R Packages, 2nd Ed.](https://r-pkgs.org/), *work in progress*
* [R Packages, 1st Ed.](http://r-pkgs.had.co.nz/)

* [What they forgot to teach you about R](https://rstats.wtf/)

* **Interface:** [Tidyverse design guide](https://design.tidyverse.org/), *work in progress*

* **Implementation:**

* Tidy evaluation:

* [Programming with dplyr](https://dplyr.tidyverse.org/articles/programming.html)
* [Using ggplot2 in packages](https://ggplot2.tidyverse.org/articles/ggplot2-in-packages.html)
* Only if you want/need the theory: [Metaprogramming in Advanced R](https://adv-r.hadley.nz/metaprogramming.html)

* Object Oriented Programming / S3: [Object Oriented Programming in Advanced R](https://adv-r.hadley.nz/oo.html)

* General R programming:
* [Advanced R](https://adv-r.hadley.nz/), in particular the Foundations part
* [Programming notes from Data Challenge Lab](https://dcl-prog.stanford.edu/)

## Overview

This is a hands on workshop for those who have embraced the tidyverse and now want to expand it to meet their own needs. We'll discuss API design, functional programming tools, the basics of object design in S3, and the tidy eval system for NSE.

At the end of the workshop participants will be able to:

* Apply an efficient workflow for building R packages,
documenting functions and unit testing using the usethis and devtools packages.

* Implement commonly used frameworks inside packages like tidy evaluation and object oriented programming.

* Critique the interface of a package and suggest improvements
that would make the package easier to learn and use.

You should take this workshop if you have experience programming in R and want to learn how to tackle larger scale problems. You'll get the most from it if you're already familiar with functions and are comfortable with R’s basic data structures (vectors, matrices, arrays, lists, and data frames).

## Is this course for me?

Have you written a few of your own R functions? Are you ready to start sharing your code (or data) through R packages? Are you curious what you can do to make your first R packages easy for your users to use, and for you to maintain?

-----

These materials closely follow https://github.com/hadley/tidy-tools

![](https://i.creativecommons.org/l/by/4.0/88x31.png) This work is
licensed under a [Creative Commons Attribution 4.0 International
License](https://creativecommons.org/licenses/by/4.0/).