Learn R Programming

tidytable (version 0.10.2)

recode: Recode values

Description

superseded

recode() has been superseded by case_match().

Replace old values of a vector with new values.

Usage

recode(.x, ..., .default = NULL, .missing = NULL)

Arguments

.x

A vector

...

A series of old = new pairs specifying the new values

.default

The default value if all conditions evaluate to FALSE

.missing

What missing values should be replaced with

Examples

Run this code
char_vec <- c("a", "b", "c")
recode(char_vec, a = "Apple", b = "Banana")

num_vec <- 1:3
recode(num_vec, `1` = 10, `2` = 25, .default = 100)

Run the code above in your browser using DataLab