You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: NEWS.md
+28-1Lines changed: 28 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,33 @@
1
1
# dplyr (development version)
2
2
3
-
*`case_when()` now determines the output size from only the LHS inputs, rather than from both the LHS and RHS inputs. This allows the legacy behavior of `TRUE ~` to continue to work, while improving `case_when()`'s safety by guarding against some silent confusing failure cases (#7082).
3
+
* In `case_when()`, supplying all size 1 LHS inputs along with a size >1 RHS input is now soft-deprecated. This is an improper usage of `case_when()` that should instead be a series of if statements, like:
4
+
5
+
```
6
+
# Scalars!
7
+
code <- 1L
8
+
flavor <- "vanilla"
9
+
10
+
# Previously
11
+
case_when(
12
+
code == 1L && flavor == "chocolate" ~ x,
13
+
code == 1L && flavor == "vanilla" ~ y,
14
+
code == 2L && flavor == "vanilla" ~ z,
15
+
.default = default
16
+
)
17
+
18
+
# Now
19
+
if (code == 1L && flavor == "chocolate") {
20
+
x
21
+
} else if (code == 1L && flavor == "vanilla") {
22
+
y
23
+
} else if (code == 2L && flavor == "vanilla") {
24
+
z
25
+
} else {
26
+
default
27
+
}
28
+
```
29
+
30
+
The recycling behavior that allows this style of `case_when()` to work is unsafe, and can result in silent bugs that we'd like to guard against with an error in the future (#7082).
4
31
5
32
* The following vector functions have gotten significantly faster and use much less memory due to a rewrite in C via vctrs (#7723):
0 commit comments