Learn R Programming

BBmisc (version 1.13)

insert: Insert elements from one list/vector into another list/vector.

Description

Inserts elements from xs2 into xs1 by name, overwriting elements of equal names.

Usage

insert(xs1, xs2, elements)

Value

x1 with replaced elements from x2.

Arguments

xs1

[list]
First list/vector.

xs2

[list]
Second vector/list. Must be fully and uniquely named.

elements

[character]
Elements from xs2 to insert into xs1. Default is all.

Examples

Run this code
xs1 = list(a = 1, b = 2)
xs2 = list(b = 1, c = 4)
insert(xs1, xs2)
insert(xs1, xs2, elements = "c")

Run the code above in your browser using DataLab