marginal: Calculate Marginal Probabilities

View source: R/marginal.R

marginalR Documentation

Calculate Marginal Probabilities

Description

Calculates marginal probabilities or counts of all selected columns. Option to include row-weights.

Usage

marginal(data, cols, weight, stat = "prob", tidy = TRUE)

Arguments

data

A data frame.

cols

Columns on which to operate, tidy-select compatible. Columns must contain only 1s and 0s (or NA), see is_onezero() for help.

weight

An optional column of row-weights.

stat

Either "prob" for probabilities or "count" for counts. Default "prob".

tidy

Logical, whether or not to return results in tidy format. Default TRUE.

Value

Returns either a vector (if tidy = FALSE), or a tibble in long form of the probabilities or counts of "A."

Examples

marginal(
    data = FoodSample,
    cols = Bisque:PorkChop,
    weight = weight,
    tidy = TRUE
)


ttrodrigz/onezero documentation built on May 9, 2023, 2:59 p.m.