- What are the observational units, variable(s), and variable type(s)?
- What did the code I used to make the plot look like?
(image source: Wikipedia)
September 20, 2017
(image source: Wikipedia)
ggplot() + geom_point(mapping = aes(x = petal_length, y = petal_width), data = iris) + ggtitle("Petal Length (cm) vs. Petal Width (cm)\nfor 150 Iris Flowers")
ggplot() + geom_point(mapping = aes(x = petal_length, y = petal_width, color = species), data = iris) + ggtitle("Petal Length (cm) vs. Petal Width (cm)\nfor 150 Iris Flowers")
versicolor <- filter(iris, species == "versicolor") ggplot() + geom_point(mapping = aes(x = petal_length, y = petal_width), data = versicolor) + ggtitle("Petal Length (cm) vs. Petal Width (cm)\nfor 150 Iris Flowers")
versicolor <- mutate(versicolor, petal_length_in = petal_length * 0.3937, petal_width_in = petal_width * 0.3937) ggplot() + geom_point(mapping = aes(x = petal_length_in, y = petal_width_in), data = versicolor) + ggtitle("Petal Length (in) vs. Petal Width (in)")
versicolor <- mutate(versicolor, z_score_length = (petal_length - mean(petal_length))/sd(petal_length), z_score_width = (petal_width - mean(petal_width))/sd(petal_width)) ggplot() + geom_point(mapping = aes(x = z_score_length, y = z_score_width), data = versicolor) + ggtitle("Petal Length vs. Petal Width")
cor(versicolor$petal_length, versicolor$petal_width)
## [1] 0.7866681