cat_summary {BioPred}R Documentation

Summarize Categorical Variables in Subgroup

Description

This function provides a summary of categorical variables in a dataset.

Usage

cat_summary(
  yvar,
  yname,
  xvars,
  xname.list,
  data,
  yvar.display = yvar,
  xvars.display = xvars
)

Arguments

yvar

Name of the variable for summary.

yname

A vector of ordered y values.

xvars

Names of the variables for grouping.

xname.list

A list (same order as xvars) of ordered x values for each xvar.

data

The dataset.

yvar.display

Display name for yvar.

xvars.display

Display name for xvars.

Value

A list containing the contingency table, frequency table, and percentage table.

Examples

# Load a sample dataset
data <- data.frame(
  outcome = sample(c("A", "B", "C"), 100, replace = TRUE),  # categorical outcome
  group1 = sample(c("Male", "Female"), 100, replace = TRUE),  # group variable 1
  group2 = sample(c("Young", "Old"), 100, replace = TRUE)  # group variable 2
)

# Summarize categorical outcome by two grouping variables
cat_summary(
  yvar = "outcome",
  yname = c("A", "B", "C"),  # ordered categories for outcome
  xvars = c("group1", "group2"),
  xname.list = list(c("Male", "Female"), c("Young", "Old")),
  data = data,
  yvar.display = "Outcome Category",
  xvars.display = c("Gender", "Age Group")
)

[Package BioPred version 1.0.2 Index]