Learn R Programming

container (version 1.0.5)

add: Add Elements to Containers

Description

Add elements to container-like objects.

Usage

add(.x, ...)

ref_add(.x, ...)

# S3 method for Container add(.x, ...)

# S3 method for Container ref_add(.x, ...)

# S3 method for Dict add(.x, ...)

# S3 method for Dict ref_add(.x, ...)

# S3 method for dict.table add(.x, ...)

# S3 method for dict.table ref_add(.x, ...)

Value

For Container, an object of class Container (or one of the respective derived classes).

For dict.table an object of class dict.table.

Arguments

.x

an R object of the respective class.

...

elements to be added.

Examples

Run this code

co = container(1)
add(co, 1, b = 2, c = container(1:3))

s = setnew(1)
add(s, 1, 1, b = 2, "1", co = container(1, 1))

d = dict(a = 1)
add(d, b = 2, co = container(1:3))

try(add(d, a = 7:9))  # key 'a' already in Dict

dit = dict.table(a = 1:3)
add(dit, b = 3:1, d = 4:6)

try(add(dit, a = 7:9))  # column 'a' already exists

dit = dict.table(a = 1:3)
add(dit, b = 3:1, d = 4:6)

try(add(dit, a = 7:9))  # column 'a' already exists

Run the code above in your browser using DataLab