The objectives of this problem set is to gain experience working with the ggplot2 package for data visualization. To do this I have provided a series of graphics, all created using the ggplot2 package. Your objective for this assignment will be write the code necessary to exactly recreate the provided graphics.
When completed submit a link to your file on rpubs.com. Be sure to include echo = TRUE for each graphic so that I can see the visualization and the code required to create it.
suppressMessages(library(ggplot2))
data <- mpg
mpg.plot <- ggplot(mpg)
mpg.plot + geom_bar(aes(class, fill = trans)) + scale_fill_discrete(name = "Transmissions")
ggplot(mpg, aes(manufacturer,hwy)) + geom_boxplot() + xlab("Vehicle Manufacturer") + ylab("Highway Fuel Efficiency (miles/gallon)") + coord_flip() + theme_classic()
suppressMessages(library(ggthemes))
data2 <- diamonds
ggplot(diamonds, aes(price)) + geom_density(aes(group = cut, col = cut, fill = cut), alpha = 0.2) + labs(title = "Diamond Price Density", x = "Diamond Price (USD)", y= "Density") + theme_economist()
data3 <- iris
ggplot(iris, aes(Sepal.Length, Petal.Length)) + geom_point() + geom_smooth(method = "lm") + labs( title = "Relationship Between Petal and Sepal Length", x= "Iris Sepal Length", y = "Iris Petal Length") + theme_minimal()
ggplot(iris, aes(Sepal.Length, Petal.Length, col = Species)) + geom_point() + geom_smooth(aes(col = Species), method = "lm", se = FALSE) + labs(title = "Relationship Between Petal and Sepal Length", subtitle = "Species level comparison", x= "Iris Sepal Length", y = "Iris Petal Length") + theme_pander() + theme(text = element_text(family = "serif"), axis.ticks = element_line(color = "black", size = 0.7), legend.position = "bottom", legend.title = element_text(face = "plain"), plot.title = element_text(size = 14, face = "plain"))