Use dplyr 1.1 'default' parameter in 'case_when()' (#1525)
* Use dplyr 1.1 'default' parameter in 'case_when()' * Update logicals.qmd --------- Co-authored-by: Hadley Wickham <hadley@posit.co>
This commit is contained in:
parent
c1e1437fd8
commit
be5039f33a
|
@ -494,13 +494,13 @@ case_when(
|
||||||
)
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
If you want to create a "default"/catch all value, use `TRUE` on the left hand side:
|
Use `.default` if you want to create a "default"/catch all value:
|
||||||
|
|
||||||
```{r}
|
```{r}
|
||||||
case_when(
|
case_when(
|
||||||
x < 0 ~ "-ve",
|
x < 0 ~ "-ve",
|
||||||
x > 0 ~ "+ve",
|
x > 0 ~ "+ve",
|
||||||
TRUE ~ "???"
|
.default = "???"
|
||||||
)
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue