dgrtwo / ebbr

Empirical Bayes binomial estimation
Other
69 stars 13 forks source link

ebb_fit_mixture error #12

Open dswatson opened 2 years ago

dswatson commented 2 years ago

I'm running into errors using the example code in the documentation for the ebb_fit_mixture function.

First, by_row appears to be from purrrlyr, which is not loaded at the top of the example. But even with this loaded, I get the following error:

# simulate some data
set.seed(2017)
sim_data <- data_frame(cluster = 1:2,
                       alpha = c(30, 35),
                       beta = c(70, 15),
                       size = c(300, 700)) %>%
  by_row(~ rbeta(.$size, .$alpha, .$beta)) %>%
  unnest(p = .out) %>%
  mutate(total = round(rlnorm(n(), 5, 2) + 1),
         x = rbinom(n(), total, p))

mm <- ebb_fit_mixture(sim_data, x, total)

Error: `.x` must be a vector, not a function
Run `rlang::last_error()` to see where the error occurred.
In addition: Warning message:
All elements of `...` must be named.
Did you want `data = c(id, x, n)`? 

I ran last_error() and got:

<error/purrr_error_bad_type>
`.x` must be a vector, not a function
Backtrace:
  1. ebbr::ebb_fit_mixture(sim_data, x, total)
 24. purrr:::stop_bad_type(...)
Run `rlang::last_trace()` to see the full context.

Any tips on how to proceed?