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.
data("mtcars")
library("ggplot2")
mtcars data set.data("mtcars")
mtcars$am=factor(mtcars$am,levels = c(0,1),labels = c("Automatic","Manual"))
ggplot(mtcars, aes(factor(am),qsec)) + geom_boxplot()+
xlab("Transmission Type")+ ylab("1/4 Mile Time") +
ggtitle("Box Plot representing values of 1/4 Mile Time vs Transmission Type")
#Summary - The 1/4 Mile type for Manual is less than that for Automatic.
carb type in mtcars.ggplot(mtcars,aes(carb))+ geom_bar(stat = "count")+
ggtitle("Number of Carb in each type")
#Summary - the number of Carb for type 2 and 4 are maximum, which is 10.
gear type and how they are further divided out by cyl.ggplot(mtcars,aes(factor(cyl), fill=factor(gear)))+
xlab("Number of Cyl")+ ylab("Gear Type")+
geom_bar()+ ggtitle("Gear divided out by Cylinder")
#Summary - Based on this graph we can summaries that gear type 4 is maximum in 4 cyl and 6 cyl and gear type 3 is maximum in 8 cyl.
wt and mpg.ggplot(mtcars,aes(wt,mpg))+
xlab("wt")+ylab("mpg")+
geom_point()+ggtitle("Relationship between wt and mpg")
#summary - From this scatter plot we can summarize that the density is highest between 3-4 wt and between 12 to 20 mpg.Also, lower the wt, more the mpg
data("mtcars")
mtcars$am=factor(mtcars$am,levels = c(0,1),labels = c("Automatic","Manual"))
ggplot(mtcars, aes(factor(am),mpg)) + geom_boxplot()+
xlab("Transmission type")+ ylab("mpg") +
ggtitle("Box Plot representing mpg and Transmission Type")
#Summary - I chose to analyze the relationship between mpg and am by using data visualization. The reason I chose to visualize this is to understand if based on the type of transmission if the mpg is affected. The factor that influences the mpg values is if the transmission is automatic or manual. Based on this we can see that Mnaual gives more mpg compared to Automatic.