| case_match | R Documentation | 
switch()Allows the user to succinctly create a new vector based off conditions of a single vector.
case_match(.x, ..., .default = NA, .ptype = NULL)
| .x | A vector | 
| ... | A sequence of two-sided formulas. The left hand side gives the old values, the right hand side gives the new value. | 
| .default | The default value if all conditions evaluate to  | 
| .ptype | Optional ptype to specify the output type. | 
df <- tidytable(x = c("a", "b", "c", "d"))
df %>%
  mutate(
    case_x = case_match(x,
                        c("a", "b") ~ "new_1",
                        "c" ~ "new_2",
                        .default = x)
  )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.