Skip to contents

Count sampled discharges and distinct hospital-years for each cell. Rows need valid hospital and year identifiers. A DuckDB input returns only grouped counts to R.

Usage

nis_cell_counts(.data, by = NULL)

Arguments

.data

Record-level data frame, lazy DuckDB query, or result of nis_design().

by

<tidy-select> Cell-defining columns. Omit or select no columns for overall counts. Use name-based selectors on DuckDB queries. The summary names n and hospitals are reserved.

Value

A data frame with the columns in by, n (unweighted discharges), and hospitals (distinct year-scoped hospitals).

Examples

nis <- nis_open(nis_example(2020))
nis_cell_counts(nis, by = DQTR)
#> # A tibble: 4 × 3
#>    DQTR     n hospitals
#>   <int> <dbl>     <dbl>
#> 1     1    24        12
#> 2     2    24        12
#> 3     3    24        12
#> 4     4    24        12