rp_calculate: Apply multiple summary functions to multiple columns

View source: R/verbs_filter.R

rp_calculateR Documentation

Apply multiple summary functions to multiple columns

Description

Applies a list of summary functions to a list of columns, after optionally grouping the data.

Usage

rp_calculate(
  .data,
  ...,
  the.functions,
  .by = NULL,
  table_name = NULL,
  return.as = "result"
)

Arguments

.data

An R data.frame.

...

Bare column names to summarize (e.g., ⁠price, carat⁠).

the.functions

A character vector of R function names (e.g., c("mean", "sd")). Supports "mean", "median", "sd", "var", "min", "max", "sum".

.by

A bare column name or c(col1, col2) to group by.

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 with the summarized and grouped data.

Examples


if (reticulate::py_available(initialize = TRUE) &&
    reticulate::py_module_available("pandas")) {

  rp_calculate(
    ggplot2::diamonds,
    price, carat,
    the.functions = c("mean", "sd"),
    .by = cut
  )
}


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