Learn R Programming

SurveyStat (version 1.0.3)

plot_boxplot: Create publication-quality box plot

Description

This function creates a clean, publication-quality box plot for numeric variables, optionally grouped by a categorical variable.

Usage

plot_boxplot(data, col, group_col = NULL, add_points = TRUE)

Value

A ggplot object

Arguments

data

A data.frame containing survey data

col

Character string specifying column name for numeric variable

group_col

Character string specifying column name for grouping variable (optional)

add_points

Logical whether to add individual data points (default: TRUE)

Examples

Run this code
data <- data.frame(age = c(25, 30, 35, 40, 45), gender = c("M", "F", "M", "F", "M"))
box_plot <- plot_boxplot(data, "age")
grouped_box <- plot_boxplot(data, "age", "gender")

Run the code above in your browser using DataLab