Use the built-in data “mpg” with the ggplot2 package to do the following:
ggplot(mpg, aes(x = manufacturer))+
geom_bar(fill = "antiquewhite4")+
theme(axis.text.x = element_text(angle = 90))+
labs(title = "How many Manufacturers form each Dealer", x = "Manufacturer", y = "Frequency" )+
theme(plot.title = element_text(size = 25))
M = mpg[,4]
barplot(table(M), xlab = NULL, ylab = "count", col = "aliceblue") +
title("Number of different cars in 1999 and 2008 from mpg dataset", font.main = 2)
## numeric(0)
ggplot(mpg, aes(x = displ , color = as.factor(cyl))) +
geom_density()+
labs(title = "Density of Engine Displacement", x = "Engine Displacement", y = "Density", color = "Cylinder")
ggplot(mpg, aes(x = cty, color = as.factor(cyl))) +
geom_density()+
labs(title = "Density of City mpg", x = "mpg in city", y = "Density", color = "Cylinder")
ggplot(mpg , aes(x = hwy, color = as.factor(cyl))) +
geom_density()+
labs(title = "Density of Highway mpg", x = "mpg on Highway", y = "Density", color = "Cylinder")
ggplot(mpg, aes(x = as.factor(cyl), y = displ))+
geom_boxplot()+
labs(title = "Engine Displacement vs Cylinder", x = "Cylinder", y = "Engine Displacement")+
theme(plot.title = element_text(size = 30))