rename_variables: Rename variables in 'draws' objects

Description Usage Arguments Value See Also Examples

View source: R/rename_variables.R

Description

Rename variables in a draws object.

Usage

1
2
3
4
rename_variables(.x, ...)

## S3 method for class 'draws'
rename_variables(.x, ...)

Arguments

.x

(draws) A draws object.

...

One or more expressions, separated by commas, indicating the variables to rename. The variable names can be unquoted (new_name = old_name) or quoted ("new_name" = "old_name"). For non-scalar variables, all elements can be renamed together ("new_name" = "old_name") or they can be renamed individually ("new_name[1]" = "old_name[1]").

Value

Returns a draws object of the same format as .x, with variables renamed according to the expressions provided in ....

See Also

variables, mutate_variables

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
x <- as_draws_df(example_draws())
variables(x)

x <- rename_variables(x, mean = mu, sigma = tau)
variables(x)

x <- rename_variables(x, b = `theta[1]`) # or b  = "theta[1]"
variables(x)

# rename all elements of 'theta' at once
x <- rename_variables(x, alpha = theta)
variables(x)

posterior documentation built on Sept. 9, 2021, 5:07 p.m.