Closed kinto-b closed 4 years ago
little_n
and successes
--> n
big_n
and sample
--> Nproportion
and probability
--> p
Also allow for summarised/unsummarised inputs:
col_freq <- function(n = double(), N = double(), p = NULL, summarised = FALSE) {
if (!summarised) {
n <- sum(n, na.rm = TRUE)
N <- sum(N, na.rm = TRUE)
if (!is.null(p)) stop("May only provide `p` if `summarised` is TRUE")
}
if (is.null(p)) p <- n / N
out <- vctrs::vec_cast_common(n, N, p, .to = double())
out <- vctrs::vec_recycle_common(!!!out)
validate_col_freq(
new_col_freq(out[[1]], out[[2]], out[[3]])
)
}
We should probably rename
successes
andsample
tolittle_n
andbig_n
respectively for consistency withcol_freq
Possibly the same is true of
probability
andproportion
. But it's less clear that that's the right way to go because theprobability
in acol_binomial
is NOT a proportion; it's an estimated probability. And since the col_binomial is created using the Agresti-Coull method, there's a substantive difference between the two.