overwrite | R Documentation |
Utility function to overwrite an object, and bypass the assignment operator.
overwrite(objname, content, environment)
objname |
Character, the name of the object to overwrite. |
content |
An R object |
environment |
The environment where to perform the overwrite procedure. |
This function does not return anything.
Adrian Dusa
foo <- function(object, x) {
objname <- deparse(substitute(object))
object <- x
overwrite(objname, object, parent.frame())
}
bar <- 1
foo(bar, 2)
bar
# [1] 2
bar <- list(A = bar)
foo(bar$A, 3)
bar
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.