Counts the number of rows (or sums a weight column) for each combination
of ..., as dplyr::count() does. It is group_by.tbl_gpu() followed by
summarise.tbl_gpu() (and arrange.tbl_gpu() with sort = TRUE), and
runs on the GPU. A grouping expression the GPU can't compute runs the whole
call in dplyr on the CPU. A .drop = FALSE grouping with a factor key, or
a table with fixed group keys (after filter(), semi_join(), ... on a
.drop = FALSE table), also reads the (small) set of group keys back into
R to add the empty groups.
Usage
# S3 method for class 'tbl_gpu'
count(
x,
...,
wt = NULL,
sort = FALSE,
name = NULL,
.drop = dplyr::group_by_drop_default(x)
)Arguments
- x
A
tbl_gpuobject created bytbl_gpu().- ...
Column names or expressions to group by (e.g.
count(df, x)orcount(df, g = x %/% 10)). A computed expression is evaluated as inmutate.tbl_gpu(). Ifxis already grouped, these are added to the existing grouping (asgroup_by(x, ..., .add = TRUE)).- wt
Optional weight column/expression. If supplied, each group's count is
sum(wt, na.rm = TRUE)instead of the row count.- sort
If
TRUE, sorts the result in descending order of the count column.- name
The name of the count column in the output. If
NULL(default), uses"n", or"nn"/"nnn"/... if"n"already names one of the grouping columns (those ofxand those in...).- .drop
Passed to
group_by.tbl_gpu(); with.drop = FALSEthe result has a zero-count row for every empty factor-level group, ingroup_data()order. Defaults togroup_by_drop_default(x).
Value
A tbl_gpu object with one row per group, containing the
grouping columns and the count column. If x was ungrouped, the result
is ungrouped; if x was grouped, the result keeps all of x's grouping,
as in dplyr (not one level less, as after summarise()).
