Skip to contents

Like count.tbl_gpu(), but without any ...: counts the rows of the groups x already has (or of the whole table, if it is ungrouped). It is one summarise.tbl_gpu() call and runs on the GPU.

Usage

# S3 method for class 'tbl_gpu'
tally(x, wt = NULL, sort = FALSE, name = NULL)

Arguments

x

A tbl_gpu object created by tbl_gpu().

wt

Optional weight column/expression, as count.tbl_gpu().

sort

If TRUE, sorts the result in descending order of the count column.

name

The name of the count column. If NULL (default), uses "n", or "nn"/"nnn"/... if "n" already names one of x's grouping columns. As in dplyr, only the grouping columns are checked, where add_count.tbl_gpu() and dplyr::add_tally() check every column.

Value

A tbl_gpu with one row per group: the grouping columns and the count column. As after summarise(), the result drops the last grouping column and keeps the others; this differs from count.tbl_gpu(), which keeps x's grouping in full.

See also

Examples

library(dplyr)
if (has_gpu()) {
  gpu_mtcars <- tbl_gpu(mtcars)
  gpu_mtcars |> group_by(cyl) |> tally() |> collect()
}
#> # A tibble: 3 × 2
#>     cyl     n
#>   <dbl> <int>
#> 1     4    11
#> 2     6     7
#> 3     8    14