slice {ir} | R Documentation |
Subset rows in ir
objects using their positions
Description
Subset rows in ir
objects using their positions
Usage
slice.ir(.data, ..., .preserve = FALSE)
slice_sample.ir(.data, ..., n, prop, weight_by = NULL, replace = FALSE)
Arguments
.data |
An object of class |
... |
For Provide either positive values to keep, or negative values to drop. The values provided must be either all positive or all negative. Indices beyond the number of rows in the input are silently ignored. For |
.preserve |
Relevant when the |
n , prop |
Provide either If a negative value of If |
weight_by |
Sampling weights. This must evaluate to a vector of non-negative numbers the same length as the input. Weights are automatically standardised to sum to 1. |
replace |
Should sampling be performed with ( |
Value
.data
with subsetted rows.
Source
See Also
Other tidyverse:
arrange.ir()
,
distinct.ir()
,
extract.ir()
,
filter-joins
,
filter.ir()
,
group_by
,
mutate-joins
,
mutate
,
nest
,
pivot_longer.ir()
,
pivot_wider.ir()
,
rename
,
rowwise.ir()
,
select.ir()
,
separate.ir()
,
separate_rows.ir()
,
summarize
,
unite.ir()
Examples
## slice
dplyr::slice(ir_sample_data, 1:5)
dplyr::slice_min(ir_sample_data, holocellulose, n = 3)
dplyr::slice_max(ir_sample_data, holocellulose, n = 3)
dplyr::slice_head(ir_sample_data, n = 5)
dplyr::slice_tail(ir_sample_data, n = 5)
## slice_sample
set.seed(234)
dplyr::slice_sample(ir_sample_data, n = 3)