mjskay / tidybayes

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

Compare_levels with unevaluated expressions cannot parse "." #174

Closed annlaurin closed 5 years ago

annlaurin commented 5 years ago

Hi,

I've run into a problem with compare_levels(). I want to make a custom comparison and use unevaluated expressions, but even with your demo data set this does not work:

fit %>% spread_draws(condition_mean[condition]) %>% compare_levels(condition_mean, by = condition, comparison = .(A-B)) I get the following error message:

Error in .(A - B) : could not find function "."

I've just updated R to version 3.6 and tidybayes to version 1.1.0, but the problem persists.

mjskay commented 5 years ago

Thanks for raising this issue! I need to update the comparison argument to use a modern modern / tidyverse approach to unevaluated expressions. In the mean time, the . function referred to in the documentation is plyr::., so something like this should work:

fit %>% 
  spread_draws(condition_mean[condition]) %>% 
  compare_levels(condition_mean, by = condition, comparison = plyr::.(A-B))

Let me know if that works. I'll clarify this in the documentation and update the comparison code to be compatible with newer ways of doing this in rlang.

annlaurin commented 5 years ago

Thanks a lot, that works!