groupStat: Perform Summary Analysis by Group Using Regular Expressions

View source: R/misc.R

groupStatR Documentation

Perform Summary Analysis by Group Using Regular Expressions

Description

This function applies a specified function to each group defined by a regular expression pattern applied to the names of a data object. It is useful for summarizing data when groups are defined by a pattern in the names rather than a specific column or index.

Usage

groupStat(f, x, xname = colnames(x), patterns)

Arguments

f

A function that takes a single argument and returns a summary of the data.

x

A data frame or matrix containing the data to be summarized.

xname

A character vector containing the names of the variables in x.

patterns

A list of regular expressions that define the groups.

Value

A list containing the summary statistics for each group.

Examples

library(easybio)
groupStat(f = \(x) x + 1, x = mtcars, patterns = list("mp", "t"))

easybio documentation built on April 12, 2025, 1:59 a.m.