-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy path4_tidyeval.Rmd
133 lines (107 loc) · 3.88 KB
/
4_tidyeval.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
---
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