Learn R Programming

poorman (version 0.2.0)

slice: Choose rows by position

Description

Choose rows by their original position in the data.frame. Grouped data.frames use the position within each group.

Usage

slice(.data, ...)

Arguments

.data

A data.frame.

...

Integer row values. Provide either positive values to keep, or negative values to drop. The values provided must be either all positive or negative. Indices beyond the number of rows in the input are silently ignored.

Examples

Run this code
# NOT RUN {
slice(mtcars, c(1, 2, 3))
mtcars %>% slice(1:3)

# }

Run the code above in your browser using DataLab