modify_by {refer} | R Documentation |
Modify an Object In Place
Description
Update the value pointed to by a ref
object. If the new value is a function,
the old values will be applied to the function and overwritten.
Usage
modify_by(x, value, ...)
Arguments
x |
object of class |
value |
new value or function applied to the object at the referenced location |
... |
additional arguments passed to the function |
Value
object of class "ref"
Examples
x <- 1:10
ref_to_x <- ref(x)
# Apply the square root function
modify_by(ref_to_x, sqrt)
print(x)
# Overwrite the original values
modify_by(ref_to_x, "hello world!")
print(x)
[Package refer version 0.1.0 Index]