Learn R Programming

ddCt (version 1.28.0)

replaceVectorByEquality: REPLACE ITEMS OF VECTOR BY EQUALITY

Description

The function replces (or updates) the items of a given vector by checking the equality with the target parameter. If found, the item will be replaced by the value parameter. The length of both target and value must be the same and could be longer than 1, in which case the replace will be iterated.

Usage

replaceVectorByEquality(vector, target, value)

Arguments

vector
A vector to be replaced. The items of the vector must be atom types, since the equality is checked by '=='.
target
targets to be replaced, could be either single or a vector
value
values to be replaced at the positions of targets, must be of the same length of target

Value

A vector of the same length as the parameter vector

Details

A warning will be prompted if any item in the target cannot be found

See Also

== for checking equality.

Examples

Run this code
vector <- c("java", "perl", "python", "c#")
replaceVectorByEquality(vector, target="c#", value="c/c++")
replaceVectorByEquality(vector, target=c("c#","perl"), value=c("c/c++","R"))

Run the code above in your browser using DataLab