From comment in #1: allow for summarised/unsummarised inputs in cols
Something like this:
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]])
)
}
From comment in #1: allow for summarised/unsummarised inputs in
col
sSomething like this:
So that we can write either
Note: this would make
encol_*
redundant