library(tidyverse)
data("mpg", package = "ggplot2")
p <-
ggplot(
data = mpg,
mapping = aes(x = hwy, y = cty)
) +
geom_point()
p
ggplot() and ggsave()*Note that you can click the three-line (hamburger) icon on the bottom-left of the slides to access a navigation menu. You can click inside the slides region and press the left and right arrow keys on your keyboard to advance and reverse the slides and animations.
Create a new scatterplot using the mpg dataset (from the {ggplot2} package).
hwy) to the x-axis.cty) to the y-axis.Using ggsave(), perform the following steps:
*Note that you can click the three-line (hamburger) icon on the bottom-left of the slides to access a navigation menu. You can click inside the slides region and press the left and right arrow keys on your keyboard to advance and reverse the slides and animations.
pressure dataset (from the “datasets” package) contains data on the relationship between temperature and vapor pressure of mercury. Create a plot to visualize this.
temperature) to the x-axis and Pressure (pressure) to the y-axis.geom_point().geom_line().mpg dataset (from the “ggplot2” package) to see if fuel efficiency data is clustered by cylinder count.
cty) to the x-axis and Highway MPG (hwy) to the y-axis.cyl) to the color aesthetic. (Note: You may want to wrap cyl in factor() so R treats it as categories rather than a continuous number).size to 3.Orange dataset (from the “datasets” package) tracks the growth of 5 specific orange trees. Create a line plot to visualize this growth.
age) to the x-axis and Circumference (circumference) to the y-axis.Tree) to the group aesthetic.geom_line().group aesthetic?*Note that you can click the three-line (hamburger) icon on the bottom-left of the slides to access a navigation menu. You can click inside the slides region and press the left and right arrow keys on your keyboard to advance and reverse the slides and animations.
mpg dataset (from the {ggplot2} package) to visualize the distribution of City MPG.
cty) to the x-axis.geom_histogram().binwidth argument to 2.mpg dataset to visualize the distribution of Vehicle Class.
class) to the x-axis.geom_bar().mpg dataset to visualize the relationship between vehicle class and Highway MPG.
class) to the x-axis.hwy) to the y-axis.geom_boxplot().mpg dataset to visualize the relationship between vehicle class and drive train.
class) to the x-axis.drv) to the fill aesthetic.geom_bar().Part (a)
Part (b)