grapes-set-grapes: Merge operator

Description Usage Arguments Value Examples

Description

Merge two objects from right to left.

Usage

1
x %<-% y

Arguments

x

A named list or vector

y

A named list or vector. Any duplicated names are detected in x will be covered by y

Value

a list

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# two lists
x <- list(a = 1, b = "foo", c = 3)
y <- list(b = 2, d = 4)
x %<-% y
y %<-% x

# one list and one vector
x <- c(foo = 1, bar = 2)
y <- list(foo = "foo")
x %<-% y
y %<-% x

# two vectors
x <- c(a = 1, b = "foo", c = 3)
y <- c(b = 2, d = 4)
x %<-% y
y %<-% x

# duplicated names in x
x <- list(a = 1, b = "foo", b = 3)
y <- list(b = 2, d = 4)
x %<-% y
y %<-% x # be careful, since "3" will cover on "foo" in x, then on "2" in y

rasterly documentation built on July 2, 2020, 2:12 a.m.