During ANLY 512 we will be studying the theory and practice of data visualization. We will be using R and the packages within R to assemble data and construct many different types of visualizations. We begin by studying some of the theoretical aspects of visualization. To do that we must appreciate the basic steps in the process of making a visualization.
The objective of this assignment is to introduce you to R markdown and to complete and explain basic plots before moving on to more complicated ways to graph data.
A couple of tips, remember that there may be preprocessing involved in your graphics so you may have to do summaries or calculations to prepare, those should be included in your work.
To ensure accuracy pay close attention to axes and labels, you will be evaluated based on the accuracy and expository nature of your graphics.
The final product of your homework (this file) should include a short summary of each graphic.
To submit this homework you will create the document in Rstudio, using the knitr package (button included in Rstudio) and then submit the document to your Rpubs account. Once uploaded you will submit the link to that document on Canvas. Please make sure that this link is hyperlinked and that I can see the visualization and the code required to create it.
Find the mtcars data in R. This is the dataset that you will use to create your graphics.
mtcars data set.data("mtcars")
if (!require('ggplot2'))
{
install.packages('ggplot2');
library(ggplot2);
}
## Loading required package: ggplot2
ggplot(data=mtcars,aes(x=factor(am),y=qsec)) + geom_boxplot() +
xlab("Transmission Type") + ylab("1/4 Mile Time") +
ggtitle("Box Plot Showing 1/4 Mile Time vs Transmission Type")
carb type in mtcars.ggplot(data=mtcars,aes(x=carb)) + geom_bar(stat="count") + ggtitle("The Number of Carb in Each Type")
gear type and how they are further divided out by cyl.ggplot(data=mtcars, aes(x = factor(cyl), fill = factor(gear))) + xlab("Number of Cyl") + ylab("Gear Type") + geom_bar() + ggtitle("The Number of Cylinders by Gear Type")
wt and mpg.ggplot(data=mtcars, aes(x = wt, y = mpg)) + xlab("wt") + ylab("mpg") + geom_point() + ggtitle("Relationship Between Variable wt and mpg")
ggplot(data=mtcars, aes(x = disp, y = mpg)) + xlab("disp") + ylab("mpg") + geom_point() + ggtitle("Relationship Between Variable disp and mpg")
Based on the plot above, we can tell that variable disp and mpg have a negative correlation, meaning when one variable increases, the other decreases. In this case, we can roughly conclude that the greater the total amount of power the engine can generate, the lesser fuel-efficient the vehicle is (mpg is the determinant of fuel efficiency.)