Created
January 24, 2019 13:47
-
-
Save DavZim/2a8cc97c0cea9c6d6f4a1557145643f3 to your computer and use it in GitHub Desktop.
Julian.Rmd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
``` 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