replaceVectorByEquality {ddCt} | R Documentation

## 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`

### Details

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

### Value

A vector of the same length as the parameter `vector`

### Author(s)

Jitao David Zhang

### See Also

`==` for checking equality.

### Examples

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

[Package ddCt version 1.40.0 Index]