Keeps rows of a GPU table by integer position, as dplyr::slice() does.
Constant positions run on the GPU, ungrouped, after group_by() and with
.by. With groups, only a strictly increasing positive index vector or a
set of negative indices runs on the GPU (an ungrouped table also takes
duplicated and reordered positions; see ... below). Anything else runs
in dplyr on the CPU (see cuplyr-fallback): an index expression that
needs the data, e.g. one that reads a column or n(), or a grouped or
.by index vector with duplicated or reordered positions.
Usage
# S3 method for class 'tbl_gpu'
slice(.data, ..., .by = NULL, .preserve = FALSE)Arguments
- .data
A
tbl_gpuobject created bytbl_gpu().- ...
Integer row positions, e.g.
slice(df, 1:3). Duplicates and reordering are allowed for positive indices when.datais ungrouped and.by=isn't supplied (slice(df, c(3, 1, 1))); grouped or.bycalls run on the GPU only for a strictly increasing, duplicate-free positive index vector (and on the CPU otherwise); negative indices drop those rows instead (order/duplicates never matter here, grouped or not);0/NAare silently dropped; out-of-range positions are silently dropped; positive and negative indices cannot be mixed.- .by
Optional grouping columns for this call only, run on the GPU. As in dplyr, the result has the groups in the order each one first appears in
.data, and it is ungrouped. Supplying.bywhen.datais already grouped (viagroup_by()) is an error, as in dplyr.- .preserve
Whether to keep the groups the slice emptied. With
TRUE, agroup_by()-grouped result keeps the input's group keys (empty groups included) forgroup_data(),collect()andsummarise(), like dplyr (seegroup_by.tbl_gpu()for what carries them on). On a.drop = FALSEtable every group is kept whatever.preservesays, as in dplyr (also forslice_head(),slice_tail(),slice_min()andslice_max()).
Details
Row order
As in dplyr: ungrouped, the rows come in the order of the positions. After
group_by() the result comes group by group, in ascending group-key order
(an NA key last), and each group's rows keep their order. With .by the
groups come in the order each first appears in .data.
