insert: Replace elements in a named vector or list

View source: R/insert.R

insertR Documentation

Replace elements in a named vector or list

Description

Given two named vectors/lists x and y and a list of names this function replaces all entries of x with the matching entries in y.

Usage

insert(x, y, which)

Arguments

x

[vector]
First vector.

y

[vector]
Second vector.

which

[character]
Entry names that should be replaced in x. Defaults to names(y).

Value

Either a vector or a list depending on the type of x and y.

Examples

x = list(a = 100, b = letters[1:3])
y = list(b = "hello", c = "world")
insert(x, y)
insert(y, x)
insert(x, y, which = "b")

jakobbossek/re documentation built on Nov. 15, 2024, 1:42 a.m.