Description Usage Arguments Examples
Create a ref as a wrapper of a given object. A ref is essentially a wrapper environment of the object.
1 | ref(object = NULL, constraint = NULL)
|
object |
The object. |
constraint |
a function to validate the value in each update of the object. |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | # create a NULL ref
ref()
# create a ref of an integer vector
x <- ref(1:10)
x[1]
x[5] <- 10L
# create a ref with constraint of an integer vector
x <- ref(1:10, is.integer)
x[1]
x[5] <- 10L
# x[5] <- "a" will corece 1:10 to character vector
# but violates is.integer contraint, leading to a stop.
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.