Recode: Recode or Replace Values With New Values

Description Usage Arguments Examples

Description

Recodes a value or a vector of values.

Usage

1
2
3
4
Recode(x, old, into, warn = TRUE)

## Default S3 method:
Recode(x, old, into, warn = TRUE)

Arguments

x

The vector whose values will be recoded.

old

the old value or a vector of old values (numeric/factor/string).

into

the new value or a vector of replacement values (1 to 1 recoding).

warn

A logical to print a message if any of the old values are not actually present in x.

Examples

1
2
3
4
5
6
x <- LETTERS[1:5]
Recode(x, c("B", "D"), c("Beta", "Delta"))

# On numeric vectors
x <- c(1, 4, 5, 9)
Recode(x, old = c(1, 4, 5, 9), into = c(10, 40, 50, 90))

SciencesPo documentation built on May 29, 2017, 9:28 p.m.