Takes an object and updates it with values from another object by replacing the values at existing names and adding values at new names of the other object. A common use case is to update parameter lists.
Usage
ref_update(object, other, ...)
# S3 method for class 'Container'
update(object, other, ...)
# S3 method for class 'Container'
ref_update(object, other, ...)
# S3 method for class 'dict.table'
update(object, other, ...)
# S3 method for class 'dict.table'
ref_update(object, other, ...)
# S3 method for class 'list'
update(object, other, ...)
Value
For Container
, an object of class Container
(or one of the
respective derived classes).
For dict.table
an object of class dict.table
.
For list
, an updated object of class list
.
Examples
d1 = dict(a = 1, b = 2)
d2 = dict( b = 0, c = 3)
update(d1, d2) # {a = 1, b = 0, c = 3}
#> {a = 1, b = 0, c = 3}
update(d2, d1) # {a = 1, b = 2, c = 3}
#> {a = 1, b = 2, c = 3}
dit1 = dict.table(a = 1:2, b = 3:4)
dit2 = dict.table( b = 5:6, c = 8:9)
update(d1, d2)
#> {a = 1, b = 0, c = 3}
update(d2, d1)
#> {a = 1, b = 2, c = 3}
l1 = list(1, b = 2)
l2 = list( b = 0, c = 3)
update(l1, l2)
#> [[1]]
#> [1] 1
#>
#> $b
#> [1] 0
#>
#> $c
#> [1] 3
#>
update(l2, l1)
#> $b
#> [1] 2
#>
#> $c
#> [1] 3
#>
#> [[3]]
#> [1] 1
#>