powered by
This function creates a clean, publication-quality histogram for numeric variables using ggplot2 with minimal theme and appropriate statistical overlays.
plot_histogram(data, col, bins = 30, add_density = TRUE)
A ggplot object
A data.frame containing survey data
Character string specifying column name for numeric variable
Number of bins for histogram (default: 30)
Logical whether to add density curve (default: TRUE)
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