LA-1

Author

K Atharsh ,Kaushik BV

Report:

Step1:Load necessary Libraries

# Load necessary libraries
library(ggplot2)
library(ggridges)

Step2:Set the dataFrame acccording to rnorms and plot it along with the region

set.seed(123)
data <- data.frame(
  age = c(rnorm(100, 30, 5), rnorm(100, 40, 7), rnorm(100, 50, 10),rnorm(100,60,12),rnorm(100,70,13),rnorm(100,80,16),rnorm(100,90,20)),
  region = rep(c("North", "South", "East","West","North-South","South-West","East-West"), each = 100)
)

Step3:Use ggplot to plot the graph and use. the function geom_density_ridges

ggplot(data, aes(x = age, y = region, fill = region)) +
  geom_density_ridges(alpha = 0.7) +
  labs(title ="Age Distribution by Region",
       x = "Age",
       y = "Region")
Picking joint bandwidth of 4.05

Step 4: Use theme_Minimal to remove the shaded region of the grid

ggplot(data, aes(x = age, y = region, fill = region)) +
  geom_density_ridges(alpha = 0.7) +
  labs(title = "Age Distribution by Region",
       x = "Age",
       y = "Region")+
  theme_minimal()
Picking joint bandwidth of 4.05