add {container}R Documentation

Add Elements to Containers

Description

Add elements to container-like objects.

Usage

add(.x, ...)

ref_add(.x, ...)

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

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

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

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

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

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

Arguments

.x

an R object of the respective class.

...

elements to be added.

Value

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

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

Note

While add uses copy semantics ref_add works by reference.

If .x is a Container, Set or Deque object, the elements being added can (but must not) be named.

If .x is a Dict or dict.table object, all elements must be of the form key = value. If one of the keys already exists, an error is given.

Examples


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

[Package container version 1.0.4 Index]