Create multiple histograms using ggplot2::facet_wrap() to visualize how a variable (eg., Sepal.Length) is distributed across different groups (eg., Species) in a built-in R dataset.
step 1: load the required libraries
library(ggplot2)#Load the iris datasetdata(iris)#view the first few rows of the datasethead(iris)
step 2: create histograms using facet_wrap for grouped data
ggplot(iris, aes(x=Sepal.Length))+geom_histogram(binwidth =0.3, fill="skyblue", color ="black")+facet_wrap(~ Species)+labs(title="Distribution of Sepal Length by Species",x="Sepal Length (cm)",y="Frequency")+theme_minimal()