translate: Translate a set of values to a new set using a dictionary

View source: R/CodeAndRoll2.R

translateR Documentation

Translate a set of values to a new set using a dictionary

Description

Replaces a set of values in a vector with another set of values, so it translates your vector. Oldvalues and newvalues have to be 1-to-1 corresponding vectors. 'chartr("a-cX", "D-Fw", x) does the same as above in theory, but it did not seem very robust regarding your input...'

Usage

translate(vec, old, new)

Arguments

vec

set of values where you want to replace

old

oldvalues, a vector of values that occur in vec to be replaced.

new

newvalues, a vector of equal length, to be copied from, corresponding 1-by-1 to old.

Examples

A <- 1:3
translate(vec = A, old = 2:3, new = letters[1:2])


vertesy/CodeAndRoll2 documentation built on Nov. 20, 2024, 5:23 a.m.