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.pie(table(mtcars$carb),main = "mtcars - Carb")
From the graph we can tell that 2 and 4 carburetors are most common and 1 is the third largest.
gear type in mtcarsand write a brief summary.barplot(table(mtcars$gear),main="Car Gears",xlab="Number of Car Gears")
From the graph, the cars with 3 gears have the biggest numbers. The second largest is the cars with 4 gears and the cars with 5 gears are the smallest.
gear type and how they are further divided out by cyland write a brief summary.barplot(table(mtcars\(cyl,mtcars\)gear), col=c(“green”,“blue”,“yellow”),main=“Number of Gears and Cylinders”,xlab=“Number of Gears”,ylab=“Cars”,legend=rownames(table(mtcars\(cyl,mtcars\)gear))) ```
Most cars with 3 gears have 8 cylinders. Nonw of the 4 gear cars have 8 gears but most of them have only 4 gears. for cars with 5 gears, there are similar number of cars that have 4 and 8 cylinders.
wt and mpgand write a brief summary.plot(mtcars$wt,mtcars$mpg, main="Car Weights and Miles per Gallon",xlab="Car Weights",ylab="Miles per Gallon")
As car weights go up, miles per gallon goes down. There is a negative linear relationship between the two variables
boxplot(mtcars$mpg~mtcars$gear,xlab="Number of Gears",ylab="Miles per Gallon")
This graoh show the relationship between numbers of hears and miles per gallon. From the graph we can tell cars with 4 gears have the most miles per gallon and cars with 3 gears have the least miles per gallon. So it is probably more cost efficient to buy a car with 4 gears.