library(ggplot2)
#Question a
#We create a bar graph for the 'manufacturer' variable and display the names at a 90 degree angle
ggplot(mpg, aes (x=manufacturer))+
geom_bar() +
theme(axis.text.x = element_text(angle=90))

#Question b
#We create a bar graph for the year variable
ggplot(mpg, aes (x=factor(year)))+
geom_bar()

#Question c
#We create density curve for the quantitative variable "displ"
ggplot(mpg, aes(x = displ, color= as.factor(cyl))) +
geom_density() +
labs(title = "Density Curve for displ", x="displ", y= "Density", color="Cylinder")

#We create density curve for the quantitative variable "cty"
ggplot(mpg, aes(x = cty, color= as.factor(cyl))) +
geom_density() +
labs(title = "Density Curve for cty", x="cty", y= "Density", color="Cylinder")

#We create density curve for the quantitative variable "hwyl"
ggplot(mpg, aes(x = hwy, color= as.factor(cyl))) +
geom_density() +
labs(title = "Density Curve for hwy", x="hwy", y= "Density", color="Cylinder")

#Question d
#We create side-by-side boxplots for displ by cyl
ggplot(mpg, aes(x = as.factor(cyl), y = displ, fill = as.factor(cyl))) +
geom_boxplot() +
labs(title = "Displ vs Cyl", subtitle = "Side-by-side boxplots for displ by cyl", x="Cyl")
