You are on page 1of 10

1.

Correlation

RSCRIPT
library(ggplot2)
library(ggcorrplot)
library(stringi)
library(dplyr)
CARS_1
str(CARS_1)
data1=CARS_1 %>%
select(engine_displacement,no_cylinder,seating_capacity,fuel_tank_capacity,rating,max_torque_nm,max_
torque_rpm,max_power_bhp,max_power_rp)
data1
cordata1=cor(data1)
cordata1
corplot=ggcorrplot(corr = cordata1,lab = T,type = "full",method = "square")
corplot

PLOT
Interpreting:
The following data has been derived from Kaggle, and the data set describes about various models of cars
and their specifications such as, no. of cylinders, fuel tank capacity and many more and prices. This data set
contains 203 rows and 16 columns or variables.
The plot shown here shows the correlation of various properties of the cars with one another. The legend
indicates that the greater will be the red colour, greater is the positive correlation. On the other hand, if the
blue colour is stronger then that represents a strong negative correlation. However, in the plot boxes, the
magnitude has also been represented by the number written in the boxes. The correlation cannot go beyond -
1 and 1. Through this plot, we study the relation between 2 variables. For example, if we pick 2 variables,
say, engine displacement and no. of cylinders, then we see a bright red colour, and the magnitude of 0.95,
which shows that there is a strong relation between number of cylinders and engine displacement. Whereas,
on the other hand, if we pick the variables fuel tank capacity and max power bhp, then we see a very weak
correlation of 0.15, which is indicated by the light red colour. The correlation of number of cylinders with
number of cylinders, or seating capacity with seating capacity will always be 1 because they are the same
things.
2. Deviation
3. Ranking
RSCRIPT

library(ggplot2)
library(ggcorrplot)
library(stringi)
library(dplyr)
CARS_1
data1barplot=ggplot(CARS_1,aes(no_cylinder))+
geom_bar(color = "red",fill=c(1:9))
data1barplot
4. Distribution
library(ggplot2)
library(ggcorrplot)
library(stringi)
library(dplyr)
CARS_1
data2=CARS_1 %>% slice(1:50)
barplot(height = data2$fuel_tank_capacity,col = c(1:50),main = "Barplot for fuel tank capacity",
xlab = "fuel tank capactiy",ylab = "count",names.arg = rownames(data2),las=2)
5. Composition

You might also like