Start by loading the dplyr and ggplot2 library as well as the
murders
and heights
data.
library(dplyr)
library(ggplot2)
library(dslabs)
data(heights)
data(murders)
With ggplot2 plots can be saved as objects. For example we can associate a dataset with a plot object like this
p <- ggplot(data = murders)
Because data
is the first argument we don’t need to spell it out
p <- ggplot(murders)
and we can also use the pipe:
p <- murders %>% ggplot()
Createp
in one of these ways and determine its class.