combine_chains {tidybayes} | R Documentation |
Combine the chain and iteration columns of tidy data frames of draws
Description
Combines the chain and iteration columns of a tidy data frame of draws from a Bayesian model fit into a new column
that can uniquely identify each draw. Generally speaking not needed for pure tidybayes code, as tidybayes
functions now automatically include a .draw
column, but can be useful when interacting with packages that
do not provide such a column.
Usage
combine_chains(data, chain = .chain, iteration = .iteration, into = ".draw")
Arguments
data |
Tidy data frame of draws with columns representing the chain and iteration of each draw. |
chain |
Bare name of column in |
iteration |
Bare name of column in |
into |
Name (as a character vector) of the column to combine chains into. The default, |
Value
A data frame of tidy draws with a combined iteration column
Author(s)
Matthew Kay
See Also
Examples
library(magrittr)
library(coda)
data(line, package = "coda")
# The `line` posterior has two chains with 200 iterations each:
line %>%
tidy_draws() %>%
summary()
# combine_chains combines the chain and iteration column into the .draw column.
line %>%
tidy_draws() %>%
combine_chains() %>%
summary()