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

tidyr deprecation warning for gather_ #297

Closed ConnorDonegan closed 2 years ago

ConnorDonegan commented 2 years ago

Hi,

When I use tidybayes::gather_draws I get a warning from tidyr:

Warning message:
`gather_()` was deprecated in tidyr 1.2.0.
Please use `gather()` instead.

Will gather_draws be updated for this?

I ask because I'm using gather_draws inside a function in the surveil package.

Thanks

Example:

library(surveil)
library(tidybayes)
df <- msa[grep("Dallas", msa$MSA),]
fit <- stan_rw(df, time = Year, group = Race, cores = 4)
gather_draws(fit$samples, rate[group_index, time_index])

returns:

# A tibble: 342,000 × 7
# Groups:   group_index, time_index, .variable [57]
   group_index time_index .chain .iteration .draw .variable  .value
         <int>      <int>  <int>      <int> <int> <chr>       <dbl>
 1           1          1      1          1     1 rate      0.00166
 2           1          1      1          2     2 rate      0.00186
 3           1          1      1          3     3 rate      0.00174
 4           1          1      1          4     4 rate      0.00186
 5           1          1      1          5     5 rate      0.00184
 6           1          1      1          6     6 rate      0.00180
 7           1          1      1          7     7 rate      0.00177
 8           1          1      1          8     8 rate      0.00163
 9           1          1      1          9     9 rate      0.00166
10           1          1      1         10    10 rate      0.00154
# … with 341,990 more rows
Warning message:
`gather_()` was deprecated in tidyr 1.2.0.
Please use `gather()` instead.
This warning is displayed once every 8 hours.
Call `lifecycle::last_lifecycle_warnings()` to see where this warning was generated. 
mjskay commented 2 years ago

Ah yup, that should be fixed on the github version but I haven't pushed to cran yet. Can you try:

devtools::install_github("mjskay/tidybayes")

and see if it is fixed? thanks!

ConnorDonegan commented 2 years ago

Yep, its good. Thanks!

mjskay commented 2 years ago

great thanks!

genos commented 1 year ago

First off, thanks very much for this awesome package.

I just encountered a similar error message when following along with vignette("tidybayes"):

 m %>% spread_draws(condition_mean[condition])
# A tibble: 20,000 × 5
# Groups:   condition [5]
   condition condition_mean .chain .iteration .draw
       <int>          <dbl>  <int>      <int> <int>
 1         1         0.264       1          1     1
 2         1         0.166       1          2     2
 3         1        -0.0398      1          3     3
 4         1         0.162       1          4     4
 5         1         0.338       1          5     5
 6         1         0.267       1          6     6
 7         1         0.136       1          7     7
 8         1         0.502       1          8     8
 9         1         0.146       1          9     9
10         1         0.0132      1         10    10
# … with 19,990 more rows
# ℹ Use `print(n = ...)` to see more rows
Warning message:
`gather_()` was deprecated in tidyr 1.2.0.
ℹ Please use `gather()` instead.
ℹ The deprecated feature was likely used in the tidybayes package.
  Please report the issue at <https://github.com/mjskay/tidybayes/issues/new>.

Is this likewise taken care of by grabbing the devel version from GitHub, or should I open a new issue? Thanks!

mjskay commented 1 year ago

should be I think --- let me know if you update to the dev version and it isn't fixed

genos commented 1 year ago

Thanks, but it looks like we still get Warning message: `gather_()` was deprecated in tidyr 1.2.0. with the dev version, copy-pasting the ABC example verbatim up to m %>% spread_draws(condition_mean[condition]).

mjskay commented 1 year ago

Weird, all calls to gather_ should be gone. Can you run devtools::install_github("mjskay/tidybayes"), restart your R session, and check? If that doesn't work, can you share the output of sessionInfo()? Thanks!

genos commented 1 year ago

That did the trick! Sorry, I must have not done the devtools step properly the previous time. Thanks for your help, this package, and your responsiveness!

mjskay commented 1 year ago

You're welcome, glad it worked!