as_rvar_factor  R Documentation 
Convert x
to an rvar_factor
or rvar_ordered
object.
as_rvar_factor(x, dim = NULL, dimnames = NULL, nchains = NULL, ...)
as_rvar_ordered(x, dim = NULL, dimnames = NULL, nchains = NULL, ...)
x 
(multiple options) An object that can be converted to an 
dim 
(integer vector) One or more integers giving the maximal indices
in each dimension to override the dimensions of the 
dimnames 
(list) Character vectors giving the names in each dimension
to override the names of the dimensions of the 
nchains 
(positive integer) The number of chains. The default is 
... 
Arguments passed on to

For objects that are already rvar
s, returns them (with modified dimensions
if dim
is not NULL
), possibly adding levels using the unique values of the draws of
the rvar
(if the object is not already factorlike).
For numeric, logical, factor, or character vectors or arrays, returns an rvar_factor
or rvar_ordered
with a single draw and the same dimensions as x
. This is in contrast
to the rvar_factor()
and rvar_ordered()
constructors, which treats the first dimension
of x
as the draws dimension. As a result, as_rvar_factor()
and as_rvar_ordered()
are useful for creating constants.
An object of class "rvar_factor"
or "rvar_ordered"
representing a random variable.
rvar()
, rvar_factor()
, and rvar_ordered()
to construct rvar
s directly.
See rdo()
, rfun()
, and rvar_rng()
for higherlevel interfaces for creating rvar
s.
# You can use as_rvar_factor() to create "constant" rvars (having only one draw):
x < as_rvar_factor("a")
x
# Such constants can be of arbitrary shape:
as_rvar_factor(letters[1:4])
as_rvar_ordered(matrix(letters[1:10], nrow = 5))
as_rvar_factor(array(letters[1:12], dim = c(2, 3, 2)))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.