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)
plotmpg<-ggplot(mpg,aes(class))
plotmpg+geom_bar(aes(fill=trans))+guides(fill=guide_legend(title="Transmission"))
library(ggplot2)
plotmpg2<-ggplot(data=mpg,aes(manufacturer,hwy))+geom_boxplot()+theme_classic()+coord_flip()+labs(y="Highway Fuel Efficiency(miles/gallon) ", x="Vehicle Manufacturer")
plotmpg2
library(ggplot2)
plotdiamond3<-ggplot(diamonds, aes(price,color=cut,fill=cut)) + geom_density(aes(fill=factor(cut)), alpha=0.2) +labs(x="Diamond Price(USD)",y="Density")+ggtitle("Diamond Price Density ")
plotdiamond3
plotiris4<-ggplot(iris, aes(x = Sepal.Length, y = Petal.Length)) +geom_jitter()+ geom_smooth(method = "lm")+theme_minimal() +theme_bw()+labs(x="Iris Sepal Length",y="Iris Petal Length")+ggtitle("Relationship between Petal and Sepal Length")+theme(panel.border = element_blank())
plotiris4
plotiris5<-ggplot(iris, aes(x = Sepal.Length, y = Petal.Length, color = Species))
plotiris5<-plotiris5+geom_point()+geom_smooth(method ="lm",se = FALSE) +theme_bw()
plotiris5<-plotiris5+labs(title="Relationship between Petal and Sepal Length",subtitle="Species level comparison",x="Iris Sepal Length",y="Iris Petal Length")
plotiris5<-plotiris5+theme(legend.position = "bottom")
plotiris5