Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

no applicable method for 'ungroup' applied to an object of class "c('double', 'numeric')" #288

Closed
tjmahr opened this issue Aug 24, 2021 · 1 comment

Comments

@tjmahr
Copy link

tjmahr commented Aug 24, 2021

This is just some light feedback about something I tripped over. Here is the problem and how to fix it.

I was running some old code.

> draws_item <- new_data_draws_item %>% 
+   add_fitted_draws(
+     m_freq_prob_comp, 
+     n = 10000, 
+     allow_new_levels = TRUE
+   )
Warning message:
`fitted_draws` and `add_fitted_draws` are deprecated as their names were confusing.
Use [add_]epred_draws() to get the expectation of the posterior predictive.
Use [add_]linpred_draws() to get the distribution of the linear predictor.
For example, you used [add_]fitted_draws(..., scale = "response"), which
means you most likely want [add_]epred_draws(...). 

This is very helpful. I change fitted to epred:

> draws_item <- new_data_draws_item %>% 
+   add_epred_draws(
+     m_freq_prob_comp, 
+     n = 10000, 
+     allow_new_levels = TRUE
+   ) 
Error in UseMethod("ungroup") : 
  no applicable method for 'ungroup' applied to an object of class "c('double', 'numeric')"

Huh? After messing around, I figured out the problem was using n instead of ndraws.

draws_item <- new_data_draws_item %>% 
  add_epred_draws(
    m_freq_prob_comp, 
    ndraws = 10000, 
    allow_new_levels = TRUE
  ) 
# works

I don't think you should change the add_() functions to have a n argument that you have to warn about. But maybe the first warning should also tell users about n being deprecated.

Anyway, if anyone else has this problem, here's what to do!

@mjskay
Copy link
Owner

mjskay commented Feb 20, 2022

Thanks, this is very helpful! Adding a note about argument name changes to the warning...

@mjskay mjskay closed this as completed in 6c63bbe Feb 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants