recodeValues: Recode or Replace Values With New Values

Description Usage Arguments Examples

Description

Recodes a value or a vector of values.

Usage

1
recodeValues(x, old, new, warn = TRUE)

Arguments

x

The vector whose values will be recoded.

old

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

new

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]
recodeValues(x, c("B", "D"), c("Beta", "Delta"))

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

danielmarcelino/SciencesPo documentation built on Oct. 20, 2019, 1:15 a.m.