Skip to contents

Generate a Table 1 style summary of data, with an optional variable to stratify descriptions (overall summary statistics are always included). Data must be in long format.

Usage

summary(data, group_var, type)

Examples

# Load repeated measures of adolescent tooth growth (must be of long format)
data <- read.csv("https://raw.githubusercontent.com/alejandroh3005/modelLong/main/data/ortho.csv")[-1]
colnames(data)[3:4] <- c("Distance", "Age")

# Summarize data, stratify by sex, and ensure age is encoded as continuous
summary_res <- modelLong::summary(
  data = data[-1],  # Ignore Subject ID
  group_var = "Sex",
  type = list(Age ~ "continuous"))

# View summary table
summary_res$table1
Variable Overall
N = 162
1
Sex
Female
N = 66
1
Male
N = 96
1
Distance 24.72 (22.50, 26.50) 23.09 (21.50, 24.60) 25.83 (23.50, 27.50)
Age 13 (10, 16) 13 (10, 16) 13 (10, 16)
1 Mean (Q1, Q3)