Analysis of the Iris Dataset

This report uses the built-in iris dataset in R. The dataset contains measurements for 150 iris flowers across three different species: setosa, versicolor, and virginica. The variables include sepal length, sepal width, petal length, and petal width.

Preview of the Dataset

data(iris)
head(iris)

The head() function shows the first six rows of the dataset.

Dataset Dimensions

dim(iris)
## [1] 150   5

The iris dataset contains 150 rows and 5 columns.

Variable Names

names(iris)
## [1] "Sepal.Length" "Sepal.Width"  "Petal.Length" "Petal.Width"  "Species"

The dataset includes the variables Sepal.Length, Sepal.Width, Petal.Length, Petal.Width, and Species.

Basic Summary Statistics

summary(iris)
##   Sepal.Length    Sepal.Width     Petal.Length    Petal.Width   
##  Min.   :4.300   Min.   :2.000   Min.   :1.000   Min.   :0.100  
##  1st Qu.:5.100   1st Qu.:2.800   1st Qu.:1.600   1st Qu.:0.300  
##  Median :5.800   Median :3.000   Median :4.350   Median :1.300  
##  Mean   :5.843   Mean   :3.057   Mean   :3.758   Mean   :1.199  
##  3rd Qu.:6.400   3rd Qu.:3.300   3rd Qu.:5.100   3rd Qu.:1.800  
##  Max.   :7.900   Max.   :4.400   Max.   :6.900   Max.   :2.500  
##        Species  
##  setosa    :50  
##  versicolor:50  
##  virginica :50  
##                 
##                 
## 

The summary() function provides basic statistics for each numeric variable, including the minimum, first quartile, median, mean, third quartile, and maximum. It also shows the number of flowers belonging to each species.

Average Sepal Length

mean(iris$Sepal.Length)
## [1] 5.843333

The average sepal length is approximately 5.84.

Average Sepal Width

mean(iris$Sepal.Width)
## [1] 3.057333

The average sepal width is approximately 3.06.

Average Petal Length

mean(iris$Petal.Length)
## [1] 3.758

The average petal length is approximately 3.76.

Average Petal Width

mean(iris$Petal.Width)
## [1] 1.199333

The average petal width is approximately 1.20.

Minimum and Maximum Petal Length

min(iris$Petal.Length)
## [1] 1
max(iris$Petal.Length)
## [1] 6.9

Petal length ranges from 1.0 to 6.9.

Flowers by Species

species_counts <- table(iris$Species)
species_counts
## 
##     setosa versicolor  virginica 
##         50         50         50

The dataset contains 50 setosa flowers, 50 versicolor flowers, and 50 virginica flowers.

Petal Length vs. Petal Width

plot(iris$Petal.Length,
     iris$Petal.Width,
     xlab = "Petal Length",
     ylab = "Petal Width",
     main = "Petal Length vs. Petal Width")

The scatter plot shows a strong positive relationship between petal length and petal width. In general, flowers with longer petals also tend to have wider petals.

Conclusion

The iris dataset provides information about the physical measurements of three different iris species. Using R, I was able to review the structure of the dataset and calculate basic summary statistics such as the mean, minimum, and maximum values. I also used a scatter plot to examine the relationship between petal length and petal width. The visualization shows that petal length and petal width tend to increase together. This analysis helped me better understand how R can be used to summarize and visualize data.