descdata: Fast descriptive statistics

View source: R/descdata.R

descdataR Documentation

Fast descriptive statistics

Description

Computes descriptive statistics for selected numeric columns using efficient C++ routines.

Usage

descdata(data, cols = NULL, stats = 1:9, first = "variables",
         cores = NULL, verbose = FALSE)

Arguments

data

A data frame, matrix, or numeric vector. If a vector is supplied, it is treated as a single variable and the output's first column is named "value".

cols

Column indices or names of numeric variables to describe. If NULL, all numeric columns are used.

stats

Statistic selection from the nine available: n, na, mean, sd, median, trimmed, min, max, IQR. Can be a numeric vector or a character vector of statistic names.

first

Name for the first column of the output, which contains the variable identifiers.

cores

Number of CPU cores. NULL (default) means single-threaded execution; pass an integer > 0 to enable OpenMP when nrow(x) * ncol(x) > 1e5.

verbose

Logical; if TRUE, prints timing message.

Details

The function accepts vectors, matrices, and data frames. Numeric columns are required. The calculation is performed entirely in C++ via Rcpp for speed.

Value

A data frame with descriptive statistics for each variable.

Author(s)

Chun-Sheng Liang <chun-shengliang@qq.com>

References

1. Example data is from https://smear.avaa.csc.fi/download. It includes particle number concentrations in SMEAR I Varrio forest.

Examples

descdata(data, cols = 5:65)
descdata(data, cols = 5:65, stats = c(2, 7:9))
descdata(data, cols = 5:65, stats = c("na", "min", "max", "IQR"))

dataprep documentation built on Oct. 1, 2026, 5:07 p.m.