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)
ggplot(mpg, aes(class,fill=trans)) + geom_bar()+guides(fill=guide_legend(title="Transmission"))
ggplot(mpg,aes(manufacturer,hwy))+geom_boxplot()+coord_flip()+
labs(y="Highway Fuel Efficiency(miles/gallon) ",
x="Vehicle Manufacturer")+theme_classic()
#install.packages("ggthemes")
library("ggthemes")
ggplot(diamonds, aes(x=price,color=cut,fill=cut)) + geom_density(aes(fill=factor(cut)), alpha=0.2) +theme_economist() + scale_colour_economist() +labs(title="Diamond Price Density ",x="Diamond Price(USD)",y="Density")
ggplot(iris, aes(x = Sepal.Length, y = Petal.Length)) + geom_point(position = "jitter")+ geom_smooth(method = "lm")+theme_minimal() + labs(title="Relationship between Petal and Sepal Length", x="Iris Sepal Length",y="Iris Petal Length")
ggplot(iris, aes(x = Sepal.Length, y = Petal.Length, color = Species)) + geom_point()+geom_smooth(method ="lm",se = F) + theme_tufte() +
labs(title="Relationship between Petal and Sepal Length",
subtitle="Species level comparison",
x="Iris Sepal Length",
y="Iris Petal Length")+theme(
legend.position = "bottom")