program 12

Program 12

Develop a script in r to create a violin plot displaynig the distribution of continous variable with seperate violins for each group using a inbuilt dataset

# Load necessary library
library(ggplot2)
# Use built-in iris dataset
data(iris)
# Create violin plot
ggplot(iris, aes(x = Species, y = Sepal.Length, fill = Species)) +
  geom_violin(trim = FALSE) +
  labs(
    title = "Distribution of Sepal Length by Species",
    x = "Species",
    y = "Sepal Length (cm)"
  ) +
  theme_minimal() +
  theme(legend.position = "none")