ANLY 512 - Problem Set 3 Exploring the Grammar of Graphics ANLY 512 Problem Set 3 Shridhar KUlkarni ## Objectives 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. ## Vis 1 This graphic is a traditional stacked bar chart. This graphic works on the mpg dataset, which is built into the ggplot2 library. This means that you can access it simply by ggplot(mpg, ....). There is one modification above default in this graphic, I renamed the legend for more clarity. ## ``` {r} data=mtcars library(ggplot2) H <- ggplot(mpg, aes (class)) H + geom_bar(aes(fill=trans)) + scale_fill_discrete(name="Transmission") ``` Vis 2 This boxplot is also built using the mpg dataset. Notice the changes in axis labels, and an altered theme_XXXX ``` {r} D <- ggplot(mpg, aes(manufacturer,hwy)) D + geom_boxplot() + coord_flip() + theme_classic()+ labs(xlab = "Vehicle Manufacturer", ylab = "Highway Fuel Efficiency (Miles/Gallon)")