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 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 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 Moodle. 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 that have different carb
values and write a brief summary.library(ggplot2)
ggplot(data=mtcars,
aes(x = factor(1), fill = factor(carb))) +
ylab("Proportions of cars by carb values") + xlab("") +
geom_bar(width = 1) +
coord_polar(theta = "y")
# Values 1,2 & 4 of carb constitue about 80% of the total carb values. This implies that 50% of the possible values(3 out of 6) constitute 80% of the total values
gear
type in mtcars
and write a brief summary.ggplot(data=mtcars, aes(x=gear)) + geom_bar(stat="count") + xlab("Gears") + ylab(" # of Cars")
# Of the total cars in dataset, 15 are 3 geared, 5 are 5 geared and remaining are 4 geared cars
gear
type and how they are further divided out by cyl
and write a brief summary.ggplot(mtcars,
aes(x = factor(gear), fill = factor(cyl))) +
xlab("Gears") +
ylab("# of Cars") +
geom_bar(color="black")
# Majority of the 3 geared cars (12 out of 15) have 8 cylinders, whereas majority of 4 geared cars have 4 cylinders. The distribution of types of cylinders in 5 geared cars is evenly distributed between 4 and 8 cylinders with few having 6 cylinders
wt
and mpg
and write a brief summary.plot(mtcars$wt, mtcars$mpg, xlab="Weight", ylab="Miles per Gallon")
title(" Scatter plot of wt vs mpg value", line=1)
# The scatterplot shows that heavier the car lower the Miles per gallon
plot(mtcars$hp, mtcars$mpg, xlab="Horse Power", ylab="Miles per Gallon")
title(" Scatter plot of hp vs mpg value", line=1)
# The scatterplot shows that heavier the horsepower lower the Miles per gallon