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 rendered .html file as: YourName_ANLY512_SECTION__SEMESTER_YEAR.Rmd and upload the file to the “Problem Set 3” assignmenet on Moodle.
library(ggplot2)
ggplot(mpg, aes(class,fill=trans)) + geom_bar()+guides(fill=guide_legend(title="Transmission"))
library(ggplot2)
ggplot(mpg,aes(manufacturer,hwy))+geom_boxplot()+coord_flip()+
labs(y="Highway Fuel Efficiency(miles/gallon) ",
x="Vehicle Manufacturer")+theme_classic()
library(ggplot2)
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")