Skip to contents

Subset rows of a data structure in order.

Usage

# S3 method for flowFrame
slice_max(
  .data,
  order_by,
  ...,
  n,
  prop,
  by = NULL,
  with_ties = TRUE,
  na_rm = FALSE
)

Arguments

.data

A flowFrame

order_by

Variable or function of variables to order by. To order by multiple variables, wrap them in a data frame or tibble.

...

Unused.

n, prop

Provide either n, the number of rows, or prop, the proportion of rows to select. If neither are supplied, n = 1 will be used. If n is greater than the number of rows in the group (or prop > 1), the result will be silently truncated to the group size. prop will be rounded towards zero to generate an integer number of rows.

A negative value of n or prop will be subtracted from the group size. For example, n = -2 with a group of 5 rows will select 5 - 2 = 3 rows; prop = -0.25 with 8 rows will select 8 * (1 - 0.25) = 6 rows.

by

Optionally, an unquoted selection of columns to group by for just this operation. An alternative to group_by.

with_ties

Should ties be kept together? The default, TRUE, may return more rows than you request. Use FALSE to ignore ties, and return the first n rows.

na_rm

Should missing values in order_by be removed from the result? If FALSE, NA values are sorted to the end so they will only be included if there are insufficient non-missing values to reach n/prop.

Value

An object of the same type as .data. The output has the following properties: * Each row may appear 0, 1, or many times in the output. * Columns are not modified. * Groups are not modified. * A flowFrame's identifier is preserved.

Examples


my_flowframe <- simulate_cytometry_data()$flowframe

 my_flowframe |>
   dplyr::slice_max(order_by = feature_1, n = 5)
#> flowFrame object 'V1'
#> with 5 cells and 10 observables:
#>            name       desc     range  minRange  maxRange
#> $P1   feature_1  feature_1        99         0        98
#> $P2   feature_2  feature_2        54         0        53
#> $P3   feature_3  feature_3        88         0        87
#> $P4   feature_4  feature_4        74         0        73
#> $P5   feature_5  feature_5        98         0        97
#> $P6   feature_6  feature_6        88         0        87
#> $P7   feature_7  feature_7        88         0        87
#> $P8   feature_8  feature_8        97         0        96
#> $P9   feature_9  feature_9        92         0        91
#> $P10 feature_10 feature_10       100         0        99
#> 88 keywords are stored in the 'description' slot