This function is similar to <<- with two exceptions:
rebind(name, value, env = parent.frame())if no existing binding is found, it throws an error
it does not recurse past the global environment into the attached packages
a <- 1
rebind("a", 2)
a
#> [1] 2
# Throws error if no existing binding
if (FALSE) rebind("b", 2) # \dontrun{}
local({
rebind("a", 3)
})
a
#> [1] 3
# Can't find get because doesn't look past globalenv
if (FALSE) rebind("get", 1) # \dontrun{}