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 actual steps in the process of making a visualization.
Most of us use softare to do this and have done so for so long that we have lost an appreciation for the mechanistic steps involved in accurately graphing data. We will fix that this week by creating a series of analog (meaning you draw them by hand) graphics. The visualizations you create must be numerically and visually accurate and precisely scaled. Because of that the data sets we visualize will be small.
A couple of tips, remember that there is preprocessing involved in many 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 of your graphics.
The final product of your homework (this file) should include scanned or photographed images for each question below and a short summary of the process.
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 your will submit the link to that document on Moodle.
Find the mtcars
data in R. This is the dataset that you will use to create your graphics. Use that data to draw by hand graphics for the next 4 questions.
mtcars
data set that have different carb
values.#Reading the data file
data(mtcars)
#Find the frequency of the different carburettors values
mtcarscarb = table(mtcars$carb)
#Find the percent label values
percentlabels<-round(100*mtcarscarb/sum(mtcarscarb))
#create labels for the piechart
pielabels<- paste(percentlabels, "%", sep="")
#R code for making the piechart
pie(mtcarscarb, col=rainbow(length(mtcarscarb)),labels=pielabels, main= 'Pie Chart for the number of carburettors distribution' )
#Legend for the Pie Chart
legend("topright", c("Carburetor-1","Carburetor-2","Carburetor-3","Carburetor-4","Carburetor-6","Carburetor-8" ), fill = rainbow(length(mtcarscarb)), cex=0.6 )
gear
type in mtcars
.#Find the frequency of the different gear values
counts <- table(mtcars$gear)
#R code for making the Bar Graph
barplot(counts, main="Car Distribution",
names.arg=c("3 Gears", "4 Gears", "5 Gears"))
gear
type and how they are further divded out by cyl
.# finding the frequency of different carburettor values and numer of cylinders
counts2 <- table(mtcars$cyl, mtcars$gear)
#R code for making the stacked Bargraph
barplot(counts2, main="Car Distribution by Gears and cyl", names.arg=c("3 Gears", "4 Gears", "5Gears") ,col=c("darkblue","red", "yellow"), legend = rownames(counts2))
wt
and mpg
.#R code for making the the Scatter Plot
plot(mtcars$wt,mtcars$mpg, xlab="Weight", ylab="mpg", main = "Sactter Plot Weight Of cars Vs Miles Per Gallon")
# Boxplot of MPG by Car Cylinders
boxplot(mpg~cyl,data=mtcars, main="Car Milage Data",
xlab="Number of Cylinders", ylab="Miles Per Gallon")