rp_first_k_rows: Extract the first k rows of a data frame

View source: R/verbs_filter.R

rp_first_k_rowsR Documentation

Extract the first k rows of a data frame

Description

This function returns the first k rows of the data frame. If grouping variables are provided via .by, it returns the first k rows within each group.

Usage

rp_first_k_rows(.data, k, .by = NULL, table_name = NULL, return.as = "result")

Arguments

.data

An R data frame (or tibble) to be processed.

k

An integer specifying the number of rows to return. If .by is used, returns up to k rows per group.

.by

Optional grouping variables. Can be one or more unquoted column names. When provided, the operation is performed on each group separately.

table_name

An optional character string. If provided, the generated Python code will replace the internal dataframe name with this string (e.g., "diamonds.query(...)"). This is useful for seeing the exact, copy-pasteable Python code. Defaults to NULL (uses "df").

return.as

One of "result", "code", or "all".

Value

Depending on return.as: a data frame, a character string, or a list.


rPandas documentation built on April 29, 2026, 1:07 a.m.