collapse provides the following functions to efficiently summarize and examine data:

  • qsu, shorthand for quick-summary, is an extremely fast summary command inspired by the (xt)summarize command in the STATA statistical software. It computes a set of 7 statistics (nobs, mean, sd, min, max, skewness and kurtosis) using a numerically stable one-pass method. Statistics can be computed weighted, by groups, and also within-and between entities (for multilevel / panel data).

  • qtab, shorthand for quick-table, is a faster and more versatile alternative to table. Notably, it also supports tabulations with frequency weights, as well as computing a statistic over combinations of variables. 'qtab's inherit the 'table' class, allowing for seamless application of 'table' methods.

  • descr computes a concise and detailed description of a data frame, including (sorted) frequency tables for categorical variables and various statistics and quantiles for numeric variables. It is inspired by Hmisc::describe, but about 10x faster.

  • pwcor, pwcov and pwnobs compute (weighted) pairwise correlations, covariances and observation counts on matrices and data frames. Pairwise correlations and covariances can be computed together with observation counts and p-values. The elaborate print method displays all of these statistics in a single correlation table.

  • varying very efficiently checks for the presence of any variation in data (optionally) within groups (such as panel-identifiers). A variable is variant if it has at least 2 distinct non-missing data points.

Table of Functions

Function / S3 Generic Methods Description
qsudefault, matrix, data.frame, grouped_df, pseries, pdata.frame, sfFast (grouped, weighted, panel-decomposed) summary statistics
qtabNo methods, for data frames or vectorsFast (weighted) cross tabulation
descrdefault, grouped_df (default method handles most objects)Detailed statistical description of data frame
pwcorNo methods, for matrices or data framesPairwise (weighted) correlations
pwcovNo methods, for matrices or data framesPairwise (weighted) covariances
pwnobsNo methods, for matrices or data framesPairwise observation counts
varyingdefault, matrix, data.frame, pseries, pdata.frame, grouped_dfFast variation check