Program 13

Author

Aditya Suresh

Write an R program to create multiple dot plots for grouped data, comparing the distributions of variables across different categories, using ggplot2 lib

Load library (ONLY this, no install.packages here)

library(ggplot2)
Warning: package 'ggplot2' was built under R version 4.5.3

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)
)

Multiple 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()