Skip to content

Instantly share code, notes, and snippets.

@DavZim
Created January 24, 2019 13:47
Show Gist options
  • Save DavZim/2a8cc97c0cea9c6d6f4a1557145643f3 to your computer and use it in GitHub Desktop.
Save DavZim/2a8cc97c0cea9c6d6f4a1557145643f3 to your computer and use it in GitHub Desktop.
Julian.Rmd
``` r
library(tidyverse)
df <- data_frame(x = 1:3, y = c("A", "B", "C"))
df %>%
mutate(
new_y = case_when(
y == "A" ~ "Alice",
y == "B" ~ "Bob",
y == "C" ~ "Charlie"
)
)
#> # A tibble: 3 x 3
#> x y new_y
#> <int> <chr> <chr>
#> 1 1 A Alice
#> 2 2 B Bob
#> 3 3 C Charlie
```
<sup>Created on 2019-01-24 by the [reprex package](https://reprex.tidyverse.org) (v0.2.1)</sup>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment