subset: Core data manipulation operations

View source: R/subset.R

subsetR Documentation

Core data manipulation operations

Description

Base-faithful table manipulation helpers built around explicit arguments, returning a basetable. See aggregate, count, drop, merge, move, orderrows, pick, renamecols, split, stack, summaries, uniquerows, unstack, and within for the remaining core verbs, each documented on its own page.

Usage

subset(data, subset = NULL, select = NULL, drop = FALSE, by = NULL)

transform(data, ..., .keep = TRUE, by = NULL)

reshape(data, ..., direction)

Arguments

data

A data.frame.

subset

A base-style expression evaluated against columns.

select, by

Character vectors naming columns. For subset, by names optional grouping columns: the subset expression is then evaluated within every group, so aggregate references in it (mean(x), max(x), ...) are per group; kept rows are returned in their original order. For transform, by names optional grouping columns and each expression in ... is evaluated within every group (e.g. cumsum(x) or x - mean(x) computed per group), so the result still has one row per input row. Use summaries for one row per group instead.

drop, .keep

Control flags.

...

Additional expressions or arguments passed through to helpers.

direction

Additional operation-specific controls.

Value

Most functions return a basetable.

Examples

subset(mtcars, cyl == 6, select = c("mpg", "hp"))
subset(mtcars, mpg > mean(mpg), by = "cyl")
transform(mtcars, power = hp / wt)
transform(mtcars, dev_mpg = mpg - mean(mpg), by = "cyl")

basetable documentation built on Sept. 18, 2026, 9:13 a.m.