# You can use as_rvar() to create "constant" rvars (having only one draw):
x <- as_rvar(1)
x
# Such constants can be of arbitrary shape:
as_rvar(1:4)
as_rvar(matrix(1:10, nrow = 5))
as_rvar(array(1:12, dim = c(2, 3, 2)))
# as_rvar_numeric() coerces subtypes of rvar to the base rvar type
y <- as_rvar_factor(c("a", "b", "c"))
y
as_rvar_numeric(y)
Run the code above in your browser using DataLab