This function gathers every column except grouping columns and those matching the expression
exclude into key/value columns ".variable" and ".value".
Imagine a data frame data as returned by spread_draws(fit, a[i], b[i,v]), like this:
column ".chain": the chain number
column ".iteration": the iteration number
column ".draw": the draw number
column "i": value in 1:5
column "v": value in 1:10
column "a": value of "a[i]" for draw number ".draw"
column "b": value of "b[i,v]" for draw number ".draw"
gather_variables(data) on that data frame would return a grouped
data frame (grouped by i and v), with:
column ".chain": the chain number
column ".iteration": the iteration number
column ".draw": the draw number
column "i": value in 1:5
column "v": value in 1:10
column ".variable": value in c("a", "b").
column ".value": value of "a[i]" (when ".variable" is "a";
repeated for every value of "v") or "b[i,v]" (when ".variable" is
"b") for draw number ".draw"
In this example, this call:
gather_variables(data)
Is roughly equivalent to:
data %>%
gather(.variable, .value, -c(.chain, .iteration, .draw, i, v)) %>%
group_by(.variable, .add = TRUE)