variables<- {posterior} | R Documentation |
Set variable names in draws
objects
Description
Set variable names for all variables in a draws
object. The
set_variables()
form is useful when using pipe operators.
Usage
variables(x, ...) <- value
## S3 replacement method for class 'draws_matrix'
variables(x, with_indices = TRUE, ...) <- value
## S3 replacement method for class 'draws_array'
variables(x, with_indices = TRUE, ...) <- value
## S3 replacement method for class 'draws_df'
variables(x, with_indices = TRUE, ...) <- value
## S3 replacement method for class 'draws_list'
variables(x, with_indices = TRUE, ...) <- value
## S3 replacement method for class 'draws_rvars'
variables(x, with_indices = FALSE, ...) <- value
set_variables(x, variables, ...)
Arguments
x |
(draws) A |
... |
Arguments passed to individual methods (if applicable). |
value , variables |
(character vector) new variable names. |
with_indices |
(logical) Should indices be included in variable
names? For example, if the object includes variables named |
Details
variables(x) <- value
allows you to modify the vector of variable names,
similar to how names(x) <- value
works for vectors and lists. For renaming
specific variables, set_variables(x, value)
works equivalently, but is more intuitive
when using the pipe operator.
For renaming specific variables, rename_variables()
may offer a more
convenient approach.
Value
Returns a draws
object of the same format as x
, with
variables named as specified.
See Also
variables
, rename_variables
, draws-index
Examples
x <- example_draws()
variables(x)
nvariables(x)
variables(x) <- letters[1:nvariables(x)]
# or equivalently...
x <- set_variables(x, letters[1:nvariables(x)])