Permalink
Branch: master
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
134 lines (107 sloc) 3.88 KB
---
title: "Touring tidyverse"
subtitle: "tidyeval"
author: "Misha Balyasin"
date: "2018/11/29"
output:
xaringan::moon_reader:
lib_dir: libs
css: xaringan-themer.css
nature:
highlightStyle: solarized-dark
highlightLines: true
countIncrementalSlides: false
---
```{r setup, include=FALSE}
options(htmltools.dir.version = FALSE)
```
```{r xaringan-themer, include = FALSE}
library(xaringanthemer)
solarized_dark(
header_font_google = google_font("Josefin Slab", "600"),
text_font_google = google_font("Work Sans", "300", "300i"),
code_font_google = google_font("IBM Plex Mono")
)
```
background-image: url(https://r4ds.had.co.nz/diagrams/data-science.png)
background-size: 800px
Slides, markdown and code - https://github.com/romatik/touring_the_tidyverse
---
# Plan of talks
.pull-left[
## Initial
1. Wrangle: tidyr
2. Wrangle: dplyr
3. Wrangle: lubridate, hms, blob, forcats, stringr
4. Program: purrr + glue
5. Program: tidyeval
6. Model: rsample, tidyposterior, recipes, broom
7. Beyond tidyverse (tibbletime, tidytext, janitor)
]
--
.pull-right[
## Current
1. Wrangle: tidyr -- `r emo::ji("check")`
2. Wrangle: dplyr -- `r emo::ji("check")`
3. ~~Wrangle: lubridate, hms, blob, forcats, stringr~~
4. Program: purrr ~~and glue~~ -- `r emo::ji("check")`
5. **Program: tidyeval**
6. Model: rsample, tidyposterior, recipes, broom -- `r emo::ji("construction")`
7. Beyond tidyverse (tibbletime, tidytext, janitor)
]
---
background-image: url(https://raw.githubusercontent.com/r-lib/rlang/master/man/figures/rlang.png)
background-size: 100px
background-position: 90% 6%
# rlang
The rlang package provides tools to work with core language features of R and the tidyverse:
1. The tidy eval framework, which is a well-founded system for non-standard evaluation built on quasiquotation (`!!`) and quoted arguments (`enquo()`).
1. User-friendly error reporting with backtraces and chained errors (`abort()`, `trace_back()`, `with_abort()`).
1. A consistent API for working with base types. Note that overall this is a work in progress that is still in flux.
---
# Initial commit of rlang/lazyeval
First commit: `2014-08-12 21:15` by Hadley Wickham.
Current iteration of rlang is not the first attempt to introduce quasiquotation.
```{r, eval=FALSE}
library(lazyeval)
f = function(col1, col2, new_col_name) {
mutate_call = lazyeval::interp(~ a + b,
a = as.name(col1),
b = as.name(col2))
mtcars %>% mutate_(.dots = setNames(list(mutate_call),
new_col_name))
}
```
---
# Current state
1. Current version - `r packageVersion("rlang")`.
1. https://github.com/r-lib/rlang
1. Developed by __Lionel Henry__, Hadley Wickham.
1. 2900+ commits by 31 contributors.
---
# Why tidyeval
1. Programming over quoting `tidyverse` functions (e.g., `dplyr`, `ggplot2`).
---
background-image: url(https://raw.githubusercontent.com/r-lib/rlang/master/man/figures/rlang.png)
background-size: 100px
background-position: 90% 6%
# 5 big ideas of tidyeval <sup>1</sup>
1. R code is a tree.
1. You can capture the tree by quoting.
1. Unquoting makes it easy to build trees.
1. Quoting + unquoting to write functions.
1. Quosures capture expression and environment.
.footnote[
[1] https://www.youtube.com/watch?v=nERXS3ssntw
]
---
# Resources
1. `tidyeval` book - https://tidyeval.tidyverse.org/ or `tidyeval` post - https://rpubs.com/lionel-/tidyeval-introduction
1. `tidyeval` webinar - https://www.rstudio.com/resources/webinars/tidy-eval/
1. "Tidy evaluation in 5 minutes" by Hadley Wickham - https://www.youtube.com/watch?v=nERXS3ssntw
1. Metaprogramming chapters in "Advanced R" - https://adv-r.hadley.nz/meta.html
1. `tidyeval` cheatsheet - https://www.rstudio.com/resources/cheatsheets/
---
# Contacts
http://mishabalyasin.com/
Slides, markdown and code - https://github.com/romatik/touring_the_tidyverse