set_distinct_by: Set counts to be distinct by some grouping variable.

View source: R/count_bindings.R

set_distinct_byR Documentation

Set counts to be distinct by some grouping variable.

Description

In some situations, count summaries may want to see distinct counts by a variable like subject. For example, the number of subjects in a population who had a particular adverse event. set_distinct_by allows you to set the by variables used to determine a distinct count.

Usage

set_distinct_by(e, distinct_by)

Arguments

e

A count_layer/shift_layer object

distinct_by

Variable(s) to get the distinct data.

Details

When a distinct_by value is set, distinct counts will be used by default. If you wish to combine distinct and not distinct counts, you can choose which to display in your f_str() objects using n, pct, distinct_n, and distinct_pct. Additionally, denominators may be presented using total and distinct_total

Value

The layer object with

Examples

#Load in pipe
library(magrittr)

tplyr_table(mtcars, gear) %>%
  add_layer(
    group_count(cyl) %>%
      set_distinct_by(carb)
  ) %>%
  build()

Tplyr documentation built on May 29, 2024, 10:37 a.m.