-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCORRELATION.R
54 lines (34 loc) · 1.12 KB
/
CORRELATION.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
###WELCOME TO CORRELATION
###Correlation refers to the statistical concept that studies the relationship
#### between 2 quantitative variables.
### INSTALL THE PACKAGES
install.packages("corrplot")
install.packages("ggcorrplot")
#### LOAD THE PACKAGES
library(ggplot2)
library(corrplot)
library(ggcorrplot)
### LOAD THE DATASET
store <- read.csv("RATINGS.csv")
####15.CORRELATION
####FIND AND PLOT CORRELATION BETWEEN RATINGS AND QUANTITY DEMANDED
cor(store$RATING, store$QUANTITY_DEMANDED)
plot(store$RATING, store$QUANTITY_DEMANDED)
####CORRELATION TEST
### PEARSON'S CORRELATION
cor.test(store$RATING, store$QUANTITY_DEMANDED)
### 16. CORRELATION MATRIX
####TO GET GREATER INSIGHT, LET'S WORK WITH OUR PRIMARY DATASET
store <- read.csv("FINAL DEPARTMENTAL STORE.csv")
#### FIND CORRELATION MATRIX
store<-dplyr::select_if(store, is.numeric)
r<-cor(store, use = "complete.obs")
round(r,2)
####PLOT THE CORRELATION MATRIX
###HEAT MAP
ggcorrplot(r)
#### PLOT THE SORTED LOWER TRIANGLE
ggcorrplot(r,
hc.order = TRUE,
type = "lower",
lab = TRUE)