| OpsArithmetic | R Documentation |
Binary arithmetic operators for Container() objects and
derived classes.
## S3 method for class 'Container'
x + y
## S3 method for class 'Container'
x - y
## S3 method for class 'Deque'
x + y
## S3 method for class 'Deque'
x - y
## S3 method for class 'Dict'
x + y
## S3 method for class 'Dict'
x - y
## S3 method for class 'Set'
x + y
## S3 method for class 'Set'
x - y
x, y |
Depending on the operator at least one must be of class
|
For Container, x + y combines x and y into a new container
by appending y to x.
For Container, x - y element-wise discards all items of y
from x, given the element was contained in x. The result is always a
container.
For Deque, x + y combines x and y into a new deque by
appending y to x.
For Deque, x - y element-wise removes all items of y from x,
given the element was contained in x.
For Dict, x + y combines x and y into a new dict by
updating x by y (see also [update()]).
For Dict, x - y removes all keys from x that appear in y.
For Set, x + y performs the set union.
For Set, x - y performs the set difference.
c1 = container(1, 1:2)
c2 = container(2, 1:2)
c1 + c2 # same as c(c1, c2)
c2 + c1 # same as c(c2, c1)
c1 - c2
c2 - c1
c1 - c1
# Arithmetic
d1 = deque(1, 1:2)
d2 = deque(2, 1:2)
d1 + d2 # same as c(d1, d2)
d2 + d1 # same as c(d2, d1)
d1 - d2
d2 - d1
d1 - d1
# Arithmetic
d1 = dict(a = 1, b = list(1, 2))
d2 = dict(a = 2, b = list(1, 2))
d1 + d2 # same as update(d, d2)
d2 + d1 # same as update(d2, d)
try({
c(d1, d2) # duplicated keys are not allowed for Dict
})
d1 - d2
d2 - d1
d1 - d1
# Arithmetic
s1 = setnew(1, 1:2)
s2 = setnew(2, 1:2)
s1 + s2 # same as s1 | s2 or c(c1, s2)
s2 + s1 # same
s1 - s2
s2 - s1
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.