Learn R Programming

SurveyStat (version 1.0.3)

plot_histogram: Create publication-quality histogram

Description

This function creates a clean, publication-quality histogram for numeric variables using ggplot2 with minimal theme and appropriate statistical overlays.

Usage

plot_histogram(data, col, bins = 30, add_density = TRUE)

Value

A ggplot object

Arguments

data

A data.frame containing survey data

col

Character string specifying column name for numeric variable

bins

Number of bins for histogram (default: 30)

add_density

Logical whether to add density curve (default: TRUE)

Examples

Run this code
data <- data.frame(age = rnorm(100, 35, 10))
hist_plot <- plot_histogram(data, "age")
print(hist_plot)

Run the code above in your browser using DataLab