The average sepal length, sepal width, petal
length, and petal width varies across the different Iris species.
Virginica has the highest averages for most of the variables, including
a sepal length of (6.6cm), a sepal width of (3.0cm), and a petal width
of (2.0cm). On the other hand Setosa has the smallest averages for the
most of the variables including a sepal length of (5.0cm), a petal
length of (1.4cm) and petal width of (.25). Lastly, the average values
for Versicolor typically fall between those of Setosa and Virginica,
with a sepal width of 2.8(cm), a petal length is (4.3cm), and petal
width of 1.3(cm).
#Set up Session
rm(list =ls())
gc()
## used (Mb) gc trigger (Mb) limit (Mb) max used (Mb)
## Ncells 543675 29.1 1203235 64.3 NA 700242 37.4
## Vcells 1006319 7.7 8388608 64.0 16384 1963155 15.0
#Import Data
library(datasets)
library(ggplot2)
data("iris")
head(iris)
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 1 5.1 3.5 1.4 0.2 setosa
## 2 4.9 3.0 1.4 0.2 setosa
## 3 4.7 3.2 1.3 0.2 setosa
## 4 4.6 3.1 1.5 0.2 setosa
## 5 5.0 3.6 1.4 0.2 setosa
## 6 5.4 3.9 1.7 0.4 setosa
tail(iris)
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 145 6.7 3.3 5.7 2.5 virginica
## 146 6.7 3.0 5.2 2.3 virginica
## 147 6.3 2.5 5.0 1.9 virginica
## 148 6.5 3.0 5.2 2.0 virginica
## 149 6.2 3.4 5.4 2.3 virginica
## 150 5.9 3.0 5.1 1.8 virginica
dim(iris)
## [1] 150 5
#Clean Data
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
#Rename Variables
iris <- rename(iris, "Sepal Length" = Sepal.Length, "Sepal Width" = Sepal.Width, "Petal Length" = Petal.Length, "Petal Width" = Petal.Width)
#Calculate Averages
iris1 <- group_by(iris, Species)
Average <- summarize(iris1, "Average Sepal Length" = mean(`Sepal Length`, na.rm = TRUE), "Average Sepal Width" = mean(`Sepal Width`, na.rm = TRUE), "Average Petal Length" =mean(`Petal Length`, na.rm = TRUE), "Average Petal Width" = mean(`Petal Width`, na.rm = TRUE))
#Create Bar Graphs
library(ggplot2)
Graph1 <- ggplot(iris1, aes(x = Species, y= `Sepal Length`, fill = Species)) + geom_bar(stat = "identity", position = position_dodge()) + labs(title = "Average Sepal Length(cm) Across Different Iris Flower Species", x = "Iris Species", y = "Avg Sepal Length")
Graph2 <- ggplot(iris1, aes(x = Species, y= `Sepal Width`, fill = Species)) + geom_bar(stat = "identity", position = position_dodge()) + labs(title = "Average Sepal Width(cm) Across Different Iris Flower Species", x = "Iris Species", y = "Avg Sepal Width")
Graph3 <- ggplot(iris1, aes(x = Species, y= `Petal Length`, fill = Species)) + geom_bar(stat = "identity", position = position_dodge()) + labs(title = "Average Petal Length(cm) Across Different Iris Flower Species", x = "Iris Species", y = "Avg Petal Length")
Graph4 <- ggplot(iris1, aes(x = Species, y= `Petal Width`, fill = Species)) + geom_bar(stat = "identity", position = position_dodge()) + labs(title = "Average Petal Width(cm) Across Different Iris Flower Species", x = "Iris Species", y = "Avg Petal Width")
#The average sepal length, sepal width, petal length, and petal width varies across the different Iris species. Virginica has the highest averages for most of the variables, including sepal length(6.6cm), sepal width(3.0cm), and petal width(2.0cm). On the other hand Setosa has the smallest averages for the most of the variables including sepal length(5.0), petal length(1.4cm) and petal width(.25). Lastly, the average values for Versicolor typically fall between those of Setosa and Virginica, with a sepal width is 2.8(cm), petal length is (4.3cm), and petal width is 1.3(cm).