Read file

iris <- read.csv("iris.csv")

Create plot of petal length vs petal width

plot(iris$Petal.Length, iris$Petal.Width)

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

Create plot of petal length vs petal width for setosa

iris$Species2 = as.numeric(factor(iris$Species))
setosa <- subset(iris, iris$Species == "setosa")
versicolor <- subset(iris, iris$Species == "versicolor")
virginica <- subset(iris, iris$Species == "viriginica")
plot(setosa$Petal.Length, setosa$Petal.Width, xlab = "Lenth", ylab = "Width", main = "Setosa Petals")

Create plot with different symbols for the different species

plot(iris$Petal.Length, iris$Petal.Width, xlab = "Length", ylab = "Width", main = "Iris Petals", pch = iris$Species2)

Create plot with different colors for different species

iris$Col = iris$Species2
iris$Col [iris$Species2 == 1] = "purple"
iris$Col [iris$Species2 == 2] = "gray"
iris$Col [iris$Species2 == 3] = "pink"
plot(iris$Petal.Length, iris$Petal.Width, xlab = "Length", ylab = "Width", main = "Iris Petals", pch = iris$Species2, col = iris$Col)

Create plot with symbols scaled by value of Sepal Width and colored by species

iris$Cex2 <- iris$Sepal.Width
plot(iris$Petal.Length, iris$Petal.Width, xlab = "Length", ylab = "Width", pch = iris$Species2, cex = iris$Cex2, col = iris$Col)

Create plot with a smoothing line

scatter.smooth(iris$Petal.Length, iris$Petal.Width, xlab = "Length", ylab = "Width", main = "Iris Petals")