modify_by: Modify an Object In Place

Description Usage Arguments Value Examples

View source: R/modify.R

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

1
modify_by(x, value, ...)

Arguments

x

object of class "ref"

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
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)

refer documentation built on Nov. 8, 2021, 5:08 p.m.