michael-franke / faintr

R package 'faintr' for interpretation of BRMS model fits for data from factorial design experiment
https://michael-franke.github.io/faintr/index.html
Other
2 stars 1 forks source link

`extract_cell_draws`: Output in long format #12

Open ooezenoglu opened 1 year ago

ooezenoglu commented 1 year ago

Currently, extract_cell_draws returns the draws in wide format:

> extract_cell_draws(fit)

# A draws_df: 1000 iterations, 4 chains, and 4 variables
   F:pol F:inf M:pol M:inf
1    236   264   156   153
2    235   269   135   148
3    235   265   151   168
4    197   226   146   168
5    211   229   169   175
6    164   208   156   170
7    258   273   111   142
8    286   298   180   192
9    215   251   214   222
10   231   263   189   206
# ... with 3990 more draws
# ... hidden reserved variables {'.chain', '.iteration', '.draw'}

I think it would be useful to also have an option to get the draws in long format (e.g., for easier plotting or SumStats):

# A draws_df: 1000 iterations, 4 chains, and 3 variables
   gender context draw
1       F     pol   236
2       F     pol   235
3       F     pol   235
4       F     pol   197
5       F     pol   211
6       F     pol   164
7       F     pol   258
8       F     pol   286
9       F     pol   215
10      F     pol   231
# ... with 15990 more draws
# ... hidden reserved variables {'.chain', '.iteration', '.draw'}

We could add a parameter format with "long" as default (?).

michael-franke commented 1 year ago

Yes, having both formatting options available would be great. It will otherwise be a constant repetitive wrangling-job.