Skip to contents

Count the observations in each group.

Usage

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

Arguments

x

A flowFrame

...

Variables to group by, named according to featureNames

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.

Examples

my_flowframe <-
  simulate_cytometry_data()$flowframe |>
    dplyr::mutate(
      random_group =
        sample(
          c("a", "b"),
          size = nrow(simulate_cytometry_data()$flowframe),
          replace = TRUE
        )
    )

 my_flowframe |>
   dplyr::count(random_group)
#> # A tibble: 2 × 2
#>   random_group     n
#>          <dbl> <int>
#> 1            1    40
#> 2            2    60