Program 13
Write an R program to create multiple dot plots for grouped data, comparing the distributions of variables across different categories, using ggplot2 lib
Install and load required package
install.packages(“ggplot2”) library(ggplot2)
Create sample dataset
data <- data.frame( Category = rep(c(“A”, “B”, “C”), each = 6), Group = rep(c(“G1”, “G2”), each = 3, times = 3), Value = c(5, 6, 7, 8, 9, 10, 4, 5, 6, 7, 8, 9, 6, 7, 8, 9, 10, 11) )
Create multiple (faceted) grouped dot plots
ggplot(data, aes(x = Category, y = Value, color = Group)) + geom_point(position = position_dodge(width = 0.6), size = 3) + facet_wrap(~ Group) + labs( title = “Multiple Dot Plots for Grouped Data”, x = “Category”, y = “Values”, color = “Group” ) + theme_minimal()