library(posterior)
library(dplyr)
d = posterior::example_draws()
# The default posterior::summarise_draws() summarises all variables without
# splitting out indices:
summarise_draws(d)
# The grouped_df implementation of summarise_draws() in tidybayes can handle
# output from spread_draws(), which is a grouped data table with the indices
# (here, `i`) left as columns:
d %>%
spread_draws(theta[i]) %>%
summarise_draws()
# Summary functions can also be provided, as in posterior::summarise_draws():
d %>%
spread_draws(theta[i]) %>%
summarise_draws(median, mad, rhat, ess_tail)
Run the code above in your browser using DataLab