| pool_draws | R Documentation |
Combine draws within each combination of grouping or 'by' variables in a data frame.
pool_draws(data, by = NULL)
## S3 method for class 'data.frame'
pool_draws(data, by = NULL)
## S3 method for class 'grouped_df'
pool_draws(data, by = NULL)
data |
A data frame with one or more rvecs. Can be grouped. |
by |
The variables distingishing
units after combining. Used if
|
Each combination of grouping or 'by' variables must have the same number of rows.
A data frame.
collapse_to_rvec() Convert from 'draws-and-value'
fromat to rvec format
expand_from_rvec() Convert from rvec format to
'draws-and-value' format
library(dplyr, warn.conflicts = FALSE)
df <- tibble(
a = c(1, 1, 2, 2),
x = rvec(list(1:2, 3:4, 5:6, 7:8))
)
df
df |> pool_draws(by = a)
df |> group_by(a) |> pool_draws()
df |> pool_draws()
df_big <- tibble(
a = c(1, 1, 2, 2, 1, 1, 2, 2),
b = c(1, 1, 1, 1, 2, 2, 2, 2),
x = rvec(list(1:2, 3:4, 5:6, 7:8,
9:10, 11:12, 13:14, 15:16)),
y = rvec(list(1:3, 4:6, 7:9, 10:12,
13:15, 16:18, 19:21, 22:24))
)
df_big |> pool_draws(by = c(a, b))
df_big |> group_by(a, b) |> pool_draws()
df_big |> pool_draws(by = a)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.