Learn R Programming

eDNAfuns (version 0.1.0)

tally_wide: Create contingency tables with two variables

Description

This function takes a tibble and create human readable contingency tables from two variables, either by showing number of cases in each combination or weighted by the sum of a numerical variable

Usage

tally_wide(tibble, rows, cols, wt = NULL, ...)

Value

A tibble

Arguments

tibble

A tibble containing at least two columns

rows

The column with the levels included as rows in the final table.

cols

The column with the levels included as columns in the final table.

wt

The column (numeric) whose values to add in order to fill the cells. If wt = NULL (the default), counts are returned instead of weighted sums.

...

Any parameters that can be passed to tally_wide 'values_fill' is a useful one

Examples

Run this code
 df <- tibble::tibble(
  group = c("A", "A", "B", "B", "B"),
    outcome = c("yes", "no", "yes", "yes", "no")
 )
tally_wide(df, rows = group, cols = outcome)

Run the code above in your browser using DataLab