This is a R Markdown document to find mtcars data in R. This is the dataset we will use to create the following graphics :-

data("mtcars")
summary(mtcars)
##       mpg             cyl             disp             hp       
##  Min.   :10.40   Min.   :4.000   Min.   : 71.1   Min.   : 52.0  
##  1st Qu.:15.43   1st Qu.:4.000   1st Qu.:120.8   1st Qu.: 96.5  
##  Median :19.20   Median :6.000   Median :196.3   Median :123.0  
##  Mean   :20.09   Mean   :6.188   Mean   :230.7   Mean   :146.7  
##  3rd Qu.:22.80   3rd Qu.:8.000   3rd Qu.:326.0   3rd Qu.:180.0  
##  Max.   :33.90   Max.   :8.000   Max.   :472.0   Max.   :335.0  
##       drat             wt             qsec             vs        
##  Min.   :2.760   Min.   :1.513   Min.   :14.50   Min.   :0.0000  
##  1st Qu.:3.080   1st Qu.:2.581   1st Qu.:16.89   1st Qu.:0.0000  
##  Median :3.695   Median :3.325   Median :17.71   Median :0.0000  
##  Mean   :3.597   Mean   :3.217   Mean   :17.85   Mean   :0.4375  
##  3rd Qu.:3.920   3rd Qu.:3.610   3rd Qu.:18.90   3rd Qu.:1.0000  
##  Max.   :4.930   Max.   :5.424   Max.   :22.90   Max.   :1.0000  
##        am              gear            carb      
##  Min.   :0.0000   Min.   :3.000   Min.   :1.000  
##  1st Qu.:0.0000   1st Qu.:3.000   1st Qu.:2.000  
##  Median :0.0000   Median :4.000   Median :2.000  
##  Mean   :0.4062   Mean   :3.688   Mean   :2.812  
##  3rd Qu.:1.0000   3rd Qu.:4.000   3rd Qu.:4.000  
##  Max.   :1.0000   Max.   :5.000   Max.   :8.000

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

library(ggplot2)
ggplot(data=mtcars,aes(x=factor(1),fill=factor(carb)))+ylab("Proportions of cars by 'carb' value")+xlab("")+geom_bar(width = 1)+coord_polar(theta = "y")

This pie chart helps us analyze the following:- a) Cars with 1, 2 and 4 carbs occupy majority proportion of mtcar data set. b) Cars with 6, 8 and 3 carbs occupy the least proportion of the mtcar dataset.

  1. Create a bar graph, that shows the number of each gear type in mtcars.
ggplot(data = mtcars,aes(x=gear))+geom_bar(stat = "count")

This bar graph helps to determine that 15 cars have 3 gears, more than 10 cars have 4 gears and 5 cars have 5 gears.

  1. Next show a stacked bar graph of the number of each gear type and how they are further divided out by cy1.
ggplot(mtcars,aes(x=factor(cyl),fill=factor(gear)))+xlab("Values of 'cyl'")+ylab("Values of 'count of gear'")+geom_bar(color="black")

  1. Draw a scatter plot showing the relationship between wt and mpg
ggplot(mtcars,aes(x=wt,y=mpg))+xlab("wt")+ylab("mpg")+geom_point()+geom_line()+ggtitle("Relationship between 'wt' and 'mpg'")+stat_smooth(method = "loess",formula=y~x,size=1,col="green")

This scatter plot helps us interpret that if the weight of the car is low, the mileage per gallon increases and if the weight of the car decreases the mileage per gallon increases.

  1. Design a visualization of your choice using the data and write a brief summary about why you chose that visualization.
boxplot(mtcars$mpg ~ mtcars$cyl,main="Box Plot of Mileage vs Number of Cylindets",xlab = "Number of Cylinders",ylab = "Miles per Gallon",col = "blue")

The reason why I chose boxplot as a visualtion because this helps us understand and interpret that the average miles per gallon for a car is lower for higher number of cylinders. For example A car with 8 cylinders has low mileage compared to a car with 4 cylinders which has higher mileage. Box plot visualization helps us determine this easily.