Correlation Analysis

library(datasets) summary(mtcars) str(mtcars)

cor(mtcars) round(cor(mtcars), 2)

cormatrix <- cor(mtcars)

Corrplot() - correlation plot

install.packages(“corrplot”) library(corrplot) ?corrplot corrplot(cormatrix) ##########################################

Data visualization

Univariate

1. histogram

hist(mtcars$hp)

2. Boxplot

boxplot(mtcars\(mpg) # to find outlier boxplot(mtcars\)mpg)$out

Bivariate Analysis

p, l, b values for type of plot

scatter plot

plot(mtcars\(hp, mtcars\)mpg) # both point and line chart ?plot plot(mtcars\(hp, mtcars\)mpg, “b”) plot(mtcars\(hp, mtcars\)mpg, “l”)

barplot

table(mtcars\(cyl) barplot(table(mtcars\)cyl)) barplot(sort((table(mtcars\(cyl)),col = "red")) barplot((table(mtcars\)cyl)),col = “red”) ######################################################