Learn R Programming

HelpersMG (version 5.1)

modifyVector: Modifies Elements of a Vector

Description

Modifies a vector by changing a subset of elements to match a second vector.

Usage

modifyVector(x, val, add = TRUE)

Arguments

x

A named vector.

val

A named vector with components to replace corresponding components in x.

add

If FALSE, only existing elements of x are returned.

Value

A modified version of x, with the elements of val replacing the elements of x

Details

modifyVector modifies elements of a vector

Examples

Run this code
# NOT RUN {
library("HelpersMG")
e <- c(M=10, L=20, J=30)
modifyVector(e, c(U=10, M=30))
modifyVector(e, c(U=10, M=30), add=FALSE)
# }

Run the code above in your browser using DataLab