mjskay / tidybayes

Bayesian analysis + tidy data + geoms (R package)
http://mjskay.github.io/tidybayes
GNU General Public License v3.0
710 stars 59 forks source link

unnest_rvars() broken with matrix covariates #316

Closed wds15 closed 10 months ago

wds15 commented 10 months ago

unnest_rvars is broken with matrix covariates in a tibble (or data.frame):

df <- tibble::tibble(regimen=1:3, dose_time=matrix(1:3, 3, 3), pp=posterior::rvar(rnorm(3)))

## does not work:
df |> tidybayes::unnest_rvars()
#> Error in data.frame(..., check.names = FALSE): arguments imply differing number of rows: 1, 3

## ok
df |> dplyr::select(-dose_time) |> tidybayes::unnest_rvars()
#> # A tibble: 9 × 5
#> # Groups:   regimen [3]
#>   regimen      pp .chain .iteration .draw
#>     <int>   <dbl>  <int>      <int> <int>
#> 1       1  0.124       1          1     1
#> 2       1 -0.398       1          2     2
#> 3       1  0.0752      1          3     3
#> 4       2  0.124       1          1     1
#> 5       2 -0.398       1          2     2
#> 6       2  0.0752      1          3     3
#> 7       3  0.124       1          1     1
#> 8       3 -0.398       1          2     2
#> 9       3  0.0752      1          3     3

Created on 2023-08-29 with reprex v2.0.2

mjskay commented 10 months ago

Thanks! Should be fixed in the github version now.