library(dplyr)
data(RankCorr, package = "ggdist")
# here's a data frame with some rvars
rvar_df = RankCorr %>%
spread_rvars(b[i,], tau[i])
rvar_df
# we can unnest it into long format.
# note how the result is grouped by all non-rvar input columns,
# and nested indices in `b` are converted into columns.
draws_df = rvar_df %>%
unnest_rvars()
draws_df
# calling nest_rvars() again on the result of unnest_rvars()
# recovers the original data frame
nest_rvars(draws_df)
Run the code above in your browser using DataLab