Skip to content

Commit c28991a

Browse files
authored
Breaking changes (#2602)
* Add error message to break change * Move breaking changes to top * `aes_string()` now errors on vector input * Add tidyeval breaking change * De-emphasise subset deprecation * More info about "undefined columns selected". Fixes #2591 * Note about duplicate columns from @thomasp85 * Recycling rules have been changed * Add note about free scales error * More details on guide_train breaking change. Fixes #2597 * Consistent indenting
1 parent 5e9b688 commit c28991a

File tree

1 file changed

+75
-15
lines changed

1 file changed

+75
-15
lines changed

NEWS.md

Lines changed: 75 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,80 @@
11
# ggplot2 2.2.1.9000
22

3+
## Breaking changes
4+
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+
* Error: Column `y` must be a 1d atomic vector or a list
18+
19+
Internally, ggplot2 now uses `as.data.frame(tibble::as_tibble(x))` to
20+
convert a list into a data frame. This improves ggplot2's support for
21+
list-columns (needed for sf support), at a small cost: you can no longer
22+
use matrix-columns. These are rarely used but are produced by `scale()`;
23+
to continue to use `scale()` you'll need to wrap it with `as.numeric()`,
24+
e.g. `as.numeric(scale(x))`.
25+
26+
* Error: More than one expression parsed
27+
28+
Previously `aes_string(x = c("a", "b", "c"))` silently returned
29+
`aes(x = a)`. Now this is a clear error.
30+
31+
* Error: `data` must be uniquely named but has duplicate columns
32+
33+
If layer data contains columns with identical names an error will be
34+
thrown. In earlier versions the first occuring column was chosen silently,
35+
potentially masking that the wrong data was chosen.
36+
37+
* Error: Aesthetics must be either length 1 or the same as the data
38+
39+
Layers are stricter about the columns they will combine into a single
40+
data frame. Each aesthetic now must be either the same length as the data
41+
frame or a single value. This makes silent recycling errors much less likely.
42+
43+
* Error: Free scales are only supported with `coord_cartesian()` and `coord_flip()`
44+
45+
Free scales only work with selected coordinate systems; previously you'd
46+
get an incorrect plot.
47+
48+
* Error: unused argument (output)
49+
50+
The function `guide_train()` now has an optional parameter `aesthetic`
51+
that allows you to override the `aesthetic` setting in the scale.
52+
To make your code work with the both released and development versions of
53+
ggplot2 appropriate, add `aesthetic = NULL` to the `guide_train()` method
54+
signature.
55+
56+
```R
57+
# old
58+
guide_train.legend <- function(guide, scale) {...}
59+
60+
# new
61+
guide_train.legend <- function(guide, scale, aesthetic = NULL) {...}
62+
```
63+
64+
Then, inside the function, replace `scale$aesthetics[1]`,
65+
`aesthetic %||% scale$aesthetics[1]`. (The %||% operator is defined in the
66+
rlang package).
67+
68+
```R
69+
# old
70+
setNames(list(scale$map(breaks)), scale$aesthetics[1])
71+
72+
# new
73+
setNames(list(scale$map(breaks)), aesthetic %||% scale$aesthetics[1])
74+
```
75+
76+
* The long-deprecated `subset` argument to `layer()` has been removed.
77+
378
## Tidy evaluation
479

580
* `aes()` now supports quasiquotation so that you can use `!!`, `!!!`,
@@ -189,21 +264,6 @@
189264
* `scale_type()` generic is now exported and documented. Use this if you
190265
want to extend ggplot2 to work with a new type of vector.
191266

192-
## Breaking changes
193-
194-
* The long-deprecated `subset` argument to `layer()` has been removed.
195-
196-
* Internally, ggplot2 now uses `as.data.frame(tibble::as_tibble(x))` to
197-
convert a list into a data frame. This improves ggplot2's support for
198-
list-columns (needed for sf support), at a small cost: you can no longer
199-
use matrix-columns. These are rarely used but are produced by `scale()`;
200-
to continue to use `scale()` you'll need to wrap it with `as.numeric()`,
201-
e.g. `as.numeric(scale(x))`.
202-
203-
* The function `guide_train()` now has an optional parameter `aesthetic`
204-
that allows you to override the `aesthetic` setting in the scale. This
205-
change will only affect code that implements custom guides (@clauswilke).
206-
207267
## Minor bug fixes and improvements
208268

209269
### Faceting

0 commit comments

Comments
 (0)