re_code: Recode specified values by new values

View source: R/psychometrics.R

re_codeR Documentation

Recode specified values by new values

Description

Recode specified values by new values

Usage

re_code(x, from, to)

Arguments

x

A vector, including column of data frame

from

The set of old values to be replaced by new ones

to

The set of new values to replace the old ones

Value

A vector that is the input vector but with old values replaced by new ones.

Examples

# Replace any occurrence of 1 and 2 with 101 and 201, respectively
x <- c(1, 2, 3, 4, 5, 1, 2)
re_code(x, from = c(1, 2), to = c(101, 201))

mark-andrews/psyntur documentation built on Nov. 18, 2024, 7:17 a.m.