Questions

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.

1.Draw a pie chart showing the proportion of cars from the mtcars data set that have different carb values.

# To find the number of cars for each carb number

carb_number <- table(mtcars$carb)
carb_number
## 
##  1  2  3  4  6  8 
##  7 10  3 10  1  1
  1. Draw a bar graph, that shows the number of each gear type in mtcars.
# To find the number of cars for each gear number

gear_number <- table(mtcars$gear)
gear_number
## 
##  3  4  5 
## 15 12  5
  1. Next show a stacked bar graph of the number of each gear type and how they are further divded out by cyl.
# To find the number of cars for each cyl under different gear number

gear_cyl <- table(mtcars$cyl,mtcars$gear)
gear_cyl
##    
##      3  4  5
##   4  1  8  2
##   6  2  4  1
##   8 12  0  2
  1. Draw a scatter plot showing the relationship between wt and mpg.

5.Design a visualization of your choice using the data.