Learn R Programming

posterior (version 1.6.0)

reserved_variables: Reserved variables

Description

Get names of reserved variables from objects in the posterior package.

Usage

reserved_variables(x, ...)

# S3 method for default reserved_variables(x, ...)

# S3 method for draws_matrix reserved_variables(x, ...)

# S3 method for draws_array reserved_variables(x, ...)

# S3 method for draws_df reserved_variables(x, ...)

# S3 method for draws_list reserved_variables(x, ...)

# S3 method for draws_rvars reserved_variables(x, ...)

Value

A character vector of reserved variables used in x.

Arguments

x

(draws) A draws object or another R object for which the method is defined.

...

Arguments passed to individual methods (if applicable).

Details

reserved_variables() returns the names of reserved variables in use by an object.

The following variables names are currently reserved for special use cases in all draws formats:

  • .log_weight: Log weights per draw (see weight_draws).

Further, specific for the draws_df format, there are three additional reserved variables:

  • .chain: Chain index per draw

  • .iteration: Iteration index within each chain

  • .draw: Draw index across chains

More reserved variables may be added in the future.

Examples

Run this code

x <- example_draws()
reserved_variables(x)

# if we add weights, the `.log_weight` reserved variable is used
x <- weight_draws(x, rexp(ndraws(x)))
reserved_variables(x)

Run the code above in your browser using DataLab