|  | 
| 4 | 4 |       case_when(FALSE ~ 1L, .default = 2:5) | 
| 5 | 5 |     Condition | 
| 6 | 6 |       Error in `case_when()`: | 
| 7 |  | -      ! `.default` must have size 1, not size 4. | 
|  | 7 | +      ! Can't recycle `.default` (size 4) to size 1. | 
| 8 | 8 | 
 | 
| 9 | 9 | # `.default` is part of common type computation | 
| 10 | 10 | 
 | 
| 11 | 11 |     Code | 
| 12 | 12 |       case_when(TRUE ~ 1L, .default = "x") | 
| 13 | 13 |     Condition | 
| 14 | 14 |       Error in `case_when()`: | 
| 15 |  | -      ! Can't combine `..1 (right)` <integer> and `.default` <character>. | 
|  | 15 | +      ! Can't combine <integer> and `.default` <character>. | 
| 16 | 16 | 
 | 
| 17 | 17 | # passes through `.size` correctly | 
| 18 | 18 | 
 | 
|  | 
| 35 | 35 |     Code | 
| 36 | 36 |       case_when(1 ~ NULL) | 
| 37 | 37 |     Condition | 
| 38 |  | -      Error in `case_when()`: | 
| 39 |  | -      ! `..1 (right)` must be a vector, not `NULL`. | 
|  | 38 | +      Warning: | 
|  | 39 | +      Calling `case_when()` with size 1 LHS inputs and size >1 RHS inputs was deprecated in dplyr 1.2.0. | 
|  | 40 | +      i This `case_when()` statement can result in subtle silent bugs and is very inefficient. | 
|  | 41 | +       | 
|  | 42 | +        Please use a series of if statements instead: | 
|  | 43 | +       | 
|  | 44 | +        ``` | 
|  | 45 | +        # Previously | 
|  | 46 | +        case_when(scalar_lhs1 ~ rhs1, scalar_lhs2 ~ rhs2, .default = default) | 
|  | 47 | +       | 
|  | 48 | +        # Now | 
|  | 49 | +        if (scalar_lhs1) { | 
|  | 50 | +          rhs1 | 
|  | 51 | +        } else if (scalar_lhs2) { | 
|  | 52 | +          rhs2 | 
|  | 53 | +        } else { | 
|  | 54 | +          default | 
|  | 55 | +        } | 
|  | 56 | +        ``` | 
|  | 57 | +      Error in `case_when()`: | 
|  | 58 | +      ! `..1 (left)` must be a logical vector, not an empty numeric vector. | 
| 40 | 59 | 
 | 
| 41 | 60 | --- | 
| 42 | 61 | 
 | 
|  | 
| 73 | 92 |     Output | 
| 74 | 93 |       <error/vctrs_error_incompatible_size> | 
| 75 | 94 |       Error in `case_when()`: | 
| 76 |  | -      ! Can't recycle `..1 (left)` (size 2) to match `..1 (right)` (size 3). | 
|  | 95 | +      ! Can't recycle `..1 (right)` (size 3) to match `..2 (right)` (size 2). | 
| 77 | 96 |     Code | 
| 78 | 97 |       (expect_error(case_when(c(TRUE, FALSE) ~ 1, c(FALSE, TRUE, FALSE) ~ 2, c(FALSE, | 
| 79 | 98 |         TRUE, FALSE, NA) ~ 3))) | 
|  | 
| 83 | 102 |       ! Can't recycle `..1 (left)` (size 2) to match `..2 (left)` (size 3). | 
| 84 | 103 |     Code | 
| 85 | 104 |       (expect_error(case_when(50 ~ 1:3))) | 
|  | 105 | +    Condition | 
|  | 106 | +      Warning: | 
|  | 107 | +      Calling `case_when()` with size 1 LHS inputs and size >1 RHS inputs was deprecated in dplyr 1.2.0. | 
|  | 108 | +      i This `case_when()` statement can result in subtle silent bugs and is very inefficient. | 
|  | 109 | +       | 
|  | 110 | +        Please use a series of if statements instead: | 
|  | 111 | +       | 
|  | 112 | +        ``` | 
|  | 113 | +        # Previously | 
|  | 114 | +        case_when(scalar_lhs1 ~ rhs1, scalar_lhs2 ~ rhs2, .default = default) | 
|  | 115 | +       | 
|  | 116 | +        # Now | 
|  | 117 | +        if (scalar_lhs1) { | 
|  | 118 | +          rhs1 | 
|  | 119 | +        } else if (scalar_lhs2) { | 
|  | 120 | +          rhs2 | 
|  | 121 | +        } else { | 
|  | 122 | +          default | 
|  | 123 | +        } | 
|  | 124 | +        ``` | 
| 86 | 125 |     Output | 
| 87 | 126 |       <error/rlang_error> | 
| 88 | 127 |       Error in `case_when()`: | 
|  | 
0 commit comments