SumStats_df: Tabulate descriptive statistics.

View source: R/SumStats_df.R

SumStats_dfR Documentation

Tabulate descriptive statistics.

Description

Tabulates descriptive statistics for all indicated variables in a data frame. Continuous covariates are summarized as "Mean (SD, range)". Binary covariates are summarized as the percentage of 1s.

Usage

SumStats_df(data, vars = names(data), binary = c())

Arguments

data

Data frame containing covariates of interest for compiling descriptive statistics.

vars

Character vector listing names of covariates in 'data' for which descriptive statistics are desired. Default is all columns in 'data'.

binary

Integer vector indexing elements in 'vars' that are binary covariates. Default is an empty vector.

Value

Matrix with nrow = length(vars) and 2 columns. The first column labeled "Mean (SD, range)" contains summary statistics. The second column contains the sample size for calculating summary statistics (number of non-missing values). Summary statistics for variables indicated in 'binary' will be a percent of 1s.

Author(s)

Quresh S. Latif


qureshlatif/QSLpersonal documentation built on Sept. 12, 2023, 6:24 p.m.