Skip to contents

Count the observations in each group.

Usage

# S3 method for flowSet
count(x, ..., wt = NULL, sort = FALSE, name = NULL)

Arguments

x

A flowSet

...

Variables to group by, named according to featureNames or the columns of the flowSet's pData

wt

If NULL (the default), counts the number of rows in each group. If a variable, computes sum(wt) for each group.

sort

If TRUE, will show the largest groups at the top.

name

If omitted, it will default to n. If there's already a column called n, it will use nn. If there's a column called n and nn, it'll use nnn, and so on, adding ns until it gets a new name.

Value

A data.frame containing the groupwise counts. If no columns are specified in `...`, the grouping is performed by experiment in the flowSet. Otherwise, the columns specified by `...` will be used for grouping.

Examples

my_flowset <- simulate_cytometry_data()$flowset

my_flowset |>
  dplyr::count()
#> # A tibble: 5 × 2
#>   .tidyFlowCore_identifier     n
#>   <chr>                    <int>
#> 1 V1                         100
#> 2 V2                         100
#> 3 V3                         100
#> 4 V4                         100
#> 5 V5                         100

my_flowset |>
  dplyr::count(cell_type)
#> # A tibble: 2 × 2
#>   cell_type        n
#>   <chr>        <int>
#> 1 population_a   300
#> 2 population_b   200