my_iris <- iris
## Average Sepal Length by Species
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
# Group by species and calculate the average sepal length
avg_sepal_length <- my_iris %>%
group_by(Species) %>%
summarise(Average_Sepal_Length = mean(Sepal.Length))
avg_sepal_length
Species Average_Sepal_Length
# Histogram for Sepal Length by Species
ggplot(my_iris, aes(x = Sepal.Length, fill = Species)) +
geom_histogram(alpha = 0.6, position = "dodge") +
labs(title = "Histogram of Sepal Length by Species", x = "Sepal Length")
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
# Box Plot for Sepal Length by Species
ggplot(my_iris, aes(x = Species, y = Sepal.Length, fill = Species)) +
geom_boxplot() +
labs(title = "Box Plot of Sepal Length by Species")
# Histogram for Sepal Width by Species
ggplot(my_iris, aes(x = Sepal.Width, fill = Species)) +
geom_histogram(alpha = 0.6, position = "dodge") +
labs(title = "Histogram of Sepal Width by Species", x = "Sepal Width")
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
# Box Plot for Sepal Width by Species
ggplot(my_iris, aes(x = Species, y = Sepal.Width, fill = Species)) +
geom_boxplot() +
labs(title = "Box Plot of Sepal Width by Species")
# Histogram for Petal Length by Species
ggplot(my_iris, aes(x = Petal.Length, fill = Species)) +
geom_histogram(alpha = 0.6, position = "dodge") +
labs(title = "Histogram of Petal Length by Species", x = "Petal Length")
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
# Box Plot for Petal Length by Species
ggplot(my_iris, aes(x = Species, y = Petal.Length, fill = Species)) +
geom_boxplot() +
labs(title = "Box Plot of Petal Length by Species")
# Histogram for Petal Width by Species
ggplot(my_iris, aes(x = Petal.Width, fill = Species)) +
geom_histogram(alpha = 0.6, position = "dodge") +
labs(title = "Histogram of Petal Width by Species", x = "Petal Width")
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
# Box Plot for Petal Width by Species
ggplot(my_iris, aes(x = Species, y = Petal.Width, fill = Species)) +
geom_boxplot() +
labs(title = "Box Plot of Petal Width by Species")
##The visualizations reveal clear distinctions among the three iris species in terms of sepal and petal measurements. Setosa is easily recognizable by its smaller petal lengths and widths, with minimal variation within the species. It also tends to have wider sepals compared to the other species. Versicolor represents an intermediate group, with both sepal and petal lengths generally falling between those of setosa and virginica. Virginica is characterized by its larger petal lengths and widths, indicating a greater size range. The overlapping distributions in sepal length and width suggest some similarities between versicolor and virginica, while setosa stands out with its smaller petal dimensions. These findings underscore the distinct morphological traits that can be used to identify each iris species.