R/printing.R

Defines functions tbl_sum.incidence2

#' @importFrom pillar tbl_sum
#' @export
tbl_sum.incidence2 <- function(x, ...) {

    # class and dimensions
    header <- sprintf(
        "%s x %s",
        formatC(nrow(x), big.mark = ","),
        formatC(ncol(x), big.mark = ",")
    )

    # counts
    counts <- unique(get_count_variable.incidence2(x))
    counts <- toString(counts)

    # output
    out <- c(incidence = header, `count vars` = toString(counts))

    # add groups if present
    groups <- get_group_names.incidence2(x)
    if (length(groups)) {
        groups <- toString(groups)
        out <- c(out, groups = groups)
    }

    out
}

Try the incidence2 package in your browser

Any scripts or data that you put into this service are public.

incidence2 documentation built on June 22, 2024, 11:05 a.m.