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.
library(ggplot2)
vis1 <- ggplot(mpg, aes(class))
vis1 + geom_bar(aes(fill = trans)) + scale_fill_discrete(name = "Transmission")
vis2 <- ggplot(mpg, aes(manufacturer,hwy)) + geom_boxplot() + coord_flip()
vis2 <- vis2 + labs(x = "Vehicle Manufacturer", y ="Highway Fuel Efficiency (miles/gallon)")
vis2 <- vis2 + theme_classic()
vis2
library(ggplot2)
library(ggthemes)
Vis3=ggplot(diamonds)+geom_density(aes(price, fill=cut,color = cut), alpha=0.3)+labs(title = "Diamond Price Density",x="Diamond Price (USD)",y="Density")+theme_economist()
Vis3
vis4 <- ggplot(iris, aes(x = Sepal.Length, y = Petal.Length)) + geom_point(size = 2)
vis4 <- vis4 + labs(x = "Iris Petal Length", y = "Iris Sepal Legth", title = "Relationship Between Petal and Sepal Length") + geom_smooth(method = "lm") + theme_minimal()
vis4
vis5 <- ggplot(iris, aes(x = Sepal.Length, y = Petal.Length, color = Species)) + geom_point(size = 2)
vis5 <- vis5 + labs(x = "Iris Petal Length", y = "Iris Sepal Legth", title = "Relationship Between Petal and Sepal Length", subtitle = "Species level comparison") + geom_smooth(se = FALSE, method = 'lm') + theme_tufte() + theme(legend.position = "bottom")
vis5