rp_sort: Sort rows of a data frame using pandas

View source: R/verbs_filter.R

rp_sortR Documentation

Sort rows of a data frame using pandas

Description

Sorts a data frame by one or more columns. It translates the R expressions into a pandas .sort_values() command and executes it.

Usage

rp_sort(.data, ..., table_name = NULL, return.as = "result")

Arguments

.data

An R data.frame or tibble.

...

Bare column names to sort by. Use desc(colname) to sort in descending order (e.g., ⁠cut, desc(price)⁠).

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

What to return: "result", "code", or "all".

Value

A data.frame sorted by the specified columns.

Examples


if (reticulate::py_available(initialize = TRUE) &&
    reticulate::py_module_available("pandas")) {
  
  # Sort by cut (ascending) and price (descending)
  rp_sort(ggplot2::diamonds, cut, desc(price))
}


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