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.

ref_update(object, other, ...)

# S3 method for Container
update(object, other, ...)

# S3 method for Container
ref_update(object, other, ...)

# S3 method for dict.table
update(object, other, ...)

# S3 method for dict.table
ref_update(object, other, ...)

# S3 method for list
update(object, other, ...)

Arguments

object

any R object

other

any object of the same type as object

...

additional arguments to be passed to or from methods.

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.

Details

update uses copy semantics while ref_update works by reference, that is, updates in place.

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
#>