Skip to content

Commit 756ad7b

Browse files
committed
More info about tidy eval
1 parent e0bb608 commit 756ad7b

File tree

1 file changed

+23
-16
lines changed

1 file changed

+23
-16
lines changed

NEWS.md

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,29 @@
22

33
## Breaking changes
44

5-
* ggplot2 now supports/uses tidy eval which means that the `aes()` is now
6-
a list of quosures (expression + environment pairs) rather than a list of
7-
symbols. If you compute on the contents of `aes()` you will need to use
8-
tools from rlang to extract the components that you need. If you are
9-
stuck, we're happy to help - please ask on <community.rstudio.com>.
10-
11-
A common symptom of this change is "undefined columns selected":
12-
this often occurs when the contents of `aes()` are coerced to a character
13-
vector and then used to index a data frame. This never worked reliably
14-
(i.e. it would fail if the user supplied an expression), so typically
15-
indicates that a different approach is warranted (#2591).
16-
17-
Similarly, if you compute on the `mapping` of an existing ggplot2 object you
18-
will also need to use rlang tools to extract the components you need. One
19-
common errror related to this change is "invalid 'type' (list) of argument"
20-
(#2610).
5+
* ggplot2 now supports/uses tidy evaluation (as described below). This is a
6+
major change and breaks a number of packages; we made this breaking change
7+
because it is important to make ggplot2 more programmable, and to be more
8+
consistent with the rest of the tidyverse. The best general (and detailed)
9+
introduction to tidy evaluation can be found in the meta programming
10+
chapters in [Advanced R](https://adv-r.hadley.nz).
11+
12+
The primary developer facing change is that `aes()` is now a list of
13+
quosures (expression + environment pairs) rather than a list of symbols,
14+
and you'll need to take a different approach to extracting the information
15+
you need. A common symptom of this change are errors "undefined columns
16+
selected" or "invalid 'type' (list) of argument" (#2610).
17+
18+
In this version of ggplot2, you need to describe a mapping in a string,
19+
use `quo_name()` (for shorter labels) or `quo_text()` (if you want
20+
everything). If you do need to extract the value of a variable instead use
21+
`rlang::eval_tidy()`. You may want to condition on
22+
`(packageVersion("ggplot2") <= "2.2.1")` so that your code can work with
23+
both released and development versions of ggplot2.
24+
25+
We recognise that this is a big change and if you're not already familiar
26+
with rlang, there's a lot to learn. If you are stuck, or need any help,
27+
please reach out on <https://community.rstudio.com>.
2128

2229
* Error: Column `y` must be a 1d atomic vector or a list
2330

0 commit comments

Comments
 (0)