b. [2 points] How many variables are included in the data? 5
c. [2 points] Print out the names of the variables. Sepal Length, Sepal Width, Petal Length, Petal Width, Species
d. [2 points] Report statistical summaries for Petal.Length, i.e. report minimum, maxi-
mum, median and mean values.
mean(iris$Petal.Length)
[1] 3.758
median(iris$Petal.Length)
[1] 4.35
which.max(table(iris$Petal.Length))
1.4
5
which.min(table(iris$Petal.Length))
1
1
e. [2 points] Create a box plot of Petal.Width. Label the y-axis “Petal Width (in cm)”.
Describe the shape of the distribution in the boxplot.
barplot(table(iris$Petal.Length), , xlab ="Petal Width", ylab ="in cm", col ="lightblue")
f. [2 points] Report statistical summaries for Petal.Width, i.e. report minimum, maximum,
median and mean values.
which.min(table(iris$Petal.Width))
0.5
5
which.max(table(iris$Petal.Width))
0.2
2
median(iris$Petal.Width)
[1] 1.3
mean(iris$Petal.Width)
[1] 1.199333
g. [3 points] Create a histogram of the Petal.Length variable. Label the x-axis “Petal
Length (in cm)”. Describe the shape of the distribution in the histogram. Bimodal
hist(iris$Petal.Length, main ="", xlab ="PetalLength (in cm)")
h. [5 points] Create a scatterplot with Petal.Length as the explanatory variable and
Petal.Width as the response variable. Then, change the horizontal axis label to “Petal
Length (in cm)” and the vertical axis label to “Petal Width (in cm).” Finally, report
your findings.
plot(iris$Petal.Length, iris$Petal.Width, xlab ="Petal Length (in cm)",ylab ="Petal Width (in cm)")
i. [5 points] Create side-by-side box plots of Petal.Length across the categories Species.
Label the y-axis “Petal Length (in cm)” and the x-axis “Species”.