Learn R Programming

galah (version 2.1.1)

slice_head.data_request: Subset rows using their positions

Description

[Experimental]

slice() lets you index rows by their (integer) locations. For objects of classes data_request or metadata_request, only slice_head() is currently implemented, and selects the first n rows.

If .data has been grouped using group_by(), the operation will be performed on each group, so that (e.g.) slice_head(df, n = 5) will select the first five rows in each group.

Usage

# S3 method for data_request
slice_head(.data, ..., n, prop, by = NULL)

# S3 method for metadata_request slice_head(.data, ..., n, prop, by = NULL)

Value

An amended data_request with a completed slice slot.

Arguments

.data

An object of class data_request, created using galah_call()

...

Currently ignored

n

The number of rows to be returned. If data are grouped group_by(), this operation will be performed on each group.

prop

Currently ignored.

by

Currently ignored.

Examples

Run this code
if (FALSE) {
# Limit number of rows returned to 3.
# In this case, our query returns the top 3 years with most records.
galah_call() |>
  identify("perameles") |>
  filter(year > 2010) |>
  group_by(year) |>
  count() |>
  slice_head(n = 3) |>
  collect()
}

Run the code above in your browser using DataLab