# NOT RUN {
x <- list(x = 1:10, y = 4, z = list(a = 1, b = 2))
str(x)
# Update values
str(list_modify(x, a = 1))
# Replace values
str(list_modify(x, z = 5))
str(list_modify(x, z = list(a = 1:5)))
# Remove values
str(list_modify(x, z = NULL))
# Combine values
str(list_merge(x, x = 11, z = list(a = 2:5, c = 3)))
# All these functions take dots with splicing. Use !!! or UQS() to
# splice a list of arguments:
l <- list(new = 1, y = NULL, z = 5)
str(list_modify(x, !!! l))
# In update_list() you can also use quosures and formulas to
# compute new values. This function is likely to be deprecated in
# the future
update_list(x, z1 = ~z[[1]])
update_list(x, z = rlang::quo(x + y))
# }
Run the code above in your browser using DataLab