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

Check that inputs to col_binomial are binary when summarising #8

Closed
kinto-b opened this issue Nov 12, 2020 · 0 comments
Closed

Check that inputs to col_binomial are binary when summarising #8

kinto-b opened this issue Nov 12, 2020 · 0 comments
Labels
bug Something isn't working

Comments

@kinto-b
Copy link
Contributor

kinto-b commented Nov 12, 2020

At this point:

if (!summarised) {
# Summarise unsummarised inputs
n <- sum(n, na.rm = TRUE)
N <- sum(N, na.rm = TRUE)
}

we want to do something like this:

   n <- as.integer(n)
   N <- as.integer(N)

 if (!summarised) { 
   bad_vals <- setdiff(unique(n), 0:1)
   if (length(bad_vals) > 0) stop("`n` must be binary") 

   n <- sum(n, na.rm = TRUE) 
   N <- sum(N, na.rm = TRUE) 
 } 

Possibly we want to do the same for N, although if we do that then we cannot write:

b_trials <- stats::rbinom(1000, 1, 0.5)
col_binomial(b_trials, length(b_trials))

We would have to write

b_trials <- stats::rbinom(1000, 1, 0.5)
col_binomial(b_trials, b_trials %in% 0:1)
@kinto-b kinto-b changed the title Check that inputs are binary when summarising Check that inputs to col_binomial are binary when summarising Nov 12, 2020
@kinto-b kinto-b added the bug Something isn't working label Nov 17, 2020
@kinto-b kinto-b closed this as completed in 4aceb02 Dec 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant