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.

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)
#> $a #> [1] 100 #> #> $b #> [1] "hello" #> #> $c #> [1] "world" #>
insert(y, x)
#> $b #> [1] "a" "b" "c" #> #> $c #> [1] "world" #> #> $a #> [1] 100 #>
insert(x, y, which = "b")
#> $a #> [1] 100 #> #> $b #> [1] "hello" #>