Learn R Programming

dataprep (version 0.1.8)

descdata: 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)

Value

A data frame with descriptive statistics for each variable.

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.

Author

Chun-Sheng Liang <[email protected]>

Details

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

References

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

Examples

Run this code
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"))

Run the code above in your browser using DataLab