re_code: Recode specified values by new values

Description Usage Arguments Value Examples

View source: R/psychometrics.R

Description

Recode specified values by new values

Usage

1
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

1
2
3
# 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))

psyntur documentation built on Sept. 15, 2021, 5:07 p.m.