Business Intelligence project

27th November 2023

t ID Number and Name | 137118 Fatoumata Camara | |
if (!is.element("languageserver", installed.packages()[, 1])) {
  install.packages("languageserver", dependencies = TRUE)
}
require("languageserver")
## Loading required package: languageserver
if (!is.element("e1071", installed.packages()[, 1])) {
  install.packages("e1071", dependencies = TRUE)
}
require("e1071")
## Loading required package: e1071
if (!is.element("Amelia", installed.packages()[, 1])) {
  install.packages("Amelia", dependencies = TRUE)
}
require("Amelia")
## Loading required package: Amelia

## Loading required package: Rcpp

## ## 
## ## Amelia II: Multiple Imputation
## ## (Version 1.8.1, built: 2022-11-18)
## ## Copyright (C) 2005-2023 James Honaker, Gary King and Matthew Blackwell
## ## Refer to http://gking.harvard.edu/amelia/ for more information
## ##
if (!is.element("corrplot", installed.packages()[, 1])) {
  install.packages("corrplot", dependencies = TRUE)
}
require("corrplot")
## Loading required package: corrplot

## corrplot 0.92 loaded
if (!is.element("ggcorrplot", installed.packages()[, 1])) {
  install.packages("ggcorrplot", dependencies = TRUE)
}
require("ggcorrplot")
## Loading required package: ggcorrplot

## Loading required package: ggplot2
if (require("ggplot2")) {
  require("ggplot2")
} else {
  install.packages("ggplot2", dependencies = TRUE,
                   repos = "https://cloud.r-project.org")
}


if (!is.element("caret", installed.packages()[, 1])) {
  install.packages("caret", dependencies = TRUE)
}
require("caret")
## Loading required package: caret

## Loading required package: lattice
if (require("klaR")) {
  require("klaR")
} else {
  install.packages("klaR", dependencies = TRUE,
                   repos = "https://cloud.r-project.org")
}
## Loading required package: klaR

## Loading required package: MASS
if (require("readr")) {
  require("readr")
} else {
  install.packages("readr", dependencies = TRUE,
                   repos = "https://cloud.r-project.org")
}
## Loading required package: readr
## LiblineaR 
if (require("LiblineaR")) {
  require("LiblineaR")
} else {
  install.packages("LiblineaR", dependencies = TRUE,
                   repos = "https://cloud.r-project.org")
}
## Loading required package: LiblineaR
## pROC 
if (require("pROC")) {
  require("pROC")
} else {
  install.packages("pROC", dependencies = TRUE,
                   repos = "https://cloud.r-project.org")
}
## Loading required package: pROC

## Type 'citation("pROC")' for a citation.

## 
## Attaching package: 'pROC'

## The following objects are masked from 'package:stats':
## 
##     cov, smooth, var
## dplyr 
if (require("dplyr")) {
  require("dplyr")
} else {
  install.packages("dplyr", dependencies = TRUE,
                   repos = "https://cloud.r-project.org")
}
## Loading required package: dplyr

## 
## Attaching package: 'dplyr'

## The following object is masked from 'package:MASS':
## 
##     select

## The following objects are masked from 'package:stats':
## 
##     filter, lag

## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
if (require("stats")) {
  require("stats")
} else {
  install.packages("stats", dependencies = TRUE,
                   repos = "https://cloud.r-project.org")
}

if (require("MASS")) {
  require("MASS")
} else {
  install.packages("MASS", dependencies = TRUE,
                   repos = "https://cloud.r-project.org")
}

## glmnet
if (require("glmnet")) {
  require("glmnet")
} else {
  install.packages("glmnet", dependencies = TRUE,
                   repos = "https://cloud.r-project.org")
}
## Loading required package: glmnet

## Loading required package: Matrix

## Loaded glmnet 4.1-8
if (require("kernlab")) {
  require("kernlab")
} else {
  install.packages("kernlab", dependencies = TRUE,
                   repos = "https://cloud.r-project.org")
}
## Loading required package: kernlab

## 
## Attaching package: 'kernlab'

## The following object is masked from 'package:ggplot2':
## 
##     alpha
## rpart 
if (require("rpart")) {
  require("rpart")
} else {
  install.packages("rpart", dependencies = TRUE,
                   repos = "https://cloud.r-project.org")
}
## Loading required package: rpart
## kernlab 
if (require("kernlab")) {
  require("kernlab")
} else {
  install.packages("kernlab", dependencies = TRUE,
                   repos = "https://cloud.r-project.org")
}

## randomForest 
if (require("randomForest")) {
  require("randomForest")
} else {
  install.packages("randomForest", dependencies = TRUE,
                   repos = "https://cloud.r-project.org")
}
## Loading required package: randomForest

## randomForest 4.7-1.1

## Type rfNews() to see new features/changes/bug fixes.

## 
## Attaching package: 'randomForest'

## The following object is masked from 'package:dplyr':
## 
##     combine

## The following object is masked from 'package:ggplot2':
## 
##     margin
if (require("RRF")) {
  require("RRF")
} else {
  install.packages("RRF", dependencies = TRUE,
                   repos = "https://cloud.r-project.org")
}
## Loading required package: RRF

## Registered S3 method overwritten by 'RRF':
##   method      from        
##   plot.margin randomForest

## RRF 1.9.4

## Type rrfNews() to see new features/changes/bug fixes.

## 
## Attaching package: 'RRF'

## The following objects are masked from 'package:randomForest':
## 
##     classCenter, combine, getTree, grow, importance, margin, MDSplot,
##     na.roughfix, outlier, partialPlot, treesize, varImpPlot, varUsed

## The following object is masked from 'package:dplyr':
## 
##     combine

## The following object is masked from 'package:ggplot2':
## 
##     margin
## caretEnsemble 
if (require("caretEnsemble")) {
  require("caretEnsemble")
} else {
  install.packages("caretEnsemble", dependencies = TRUE,
                   repos = "https://cloud.r-project.org")
}
## Loading required package: caretEnsemble

## 
## Attaching package: 'caretEnsemble'

## The following object is masked from 'package:ggplot2':
## 
##     autoplot
## C50 
if (require("C50")) {
  require("C50")
} else {
  install.packages("C50", dependencies = TRUE,
                   repos = "https://cloud.r-project.org")
}
## Loading required package: C50
if (require("plumber")) {
  require("plumber")
} else {
  install.packages("plumber", dependencies = TRUE,
                   repos = "https://cloud.r-project.org")
}
## Loading required package: plumber
# loading the dataset
library(readr)
SuperstoreSalesTraining <- read_csv("data/SuperstoreSalesTraining.csv")
## Rows: 12918 Columns: 12
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## dbl (12): Row, Order, Discount, UnitPrice, OrderQuantity, Sales, Profit, Shi...
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
View(SuperstoreSalesTraining)

##Descriptive Statistics----
## 1.Measures of Frequency ----
SuperstoreSalesTraining_freq <- SuperstoreSalesTraining $Item
cbind(frequency = table(SuperstoreSalesTraining_freq),
      percentage = prop.table(table(SuperstoreSalesTraining_freq)) * 100)
##      frequency  percentage
## 1            9 0.069670228
## 2           23 0.178046137
## 3           20 0.154822728
## 4           12 0.092893637
## 5           12 0.092893637
## 6           18 0.139340455
## 7            4 0.030964546
## 8           17 0.131599319
## 9           11 0.085152500
## 10          10 0.077411364
## 11          53 0.410280229
## 12          22 0.170305001
## 13          36 0.278680910
## 14          10 0.077411364
## 15          25 0.193528410
## 16          32 0.247716365
## 17          30 0.232234092
## 18          45 0.348351138
## 19          42 0.325127729
## 20          14 0.108375910
## 21          34 0.263198638
## 22          21 0.162563864
## 23          19 0.147081592
## 24          28 0.216751819
## 25          32 0.247716365
## 26          37 0.286422047
## 27          65 0.503173866
## 28          14 0.108375910
## 29          18 0.139340455
## 30          35 0.270939774
## 31          24 0.185787274
## 32          62 0.479950457
## 33          33 0.255457501
## 34          34 0.263198638
## 35          38 0.294163183
## 36          29 0.224492956
## 37          29 0.224492956
## 38          14 0.108375910
## 39          44 0.340610002
## 40          32 0.247716365
## 41          17 0.131599319
## 42          43 0.332868865
## 43          35 0.270939774
## 44          11 0.085152500
## 45          38 0.294163183
## 46          31 0.239975228
## 47          35 0.270939774
## 48          44 0.340610002
## 49          35 0.270939774
## 50          30 0.232234092
## 51          25 0.193528410
## 52          64 0.495432730
## 53          16 0.123858182
## 54          30 0.232234092
## 55          30 0.232234092
## 56          25 0.193528410
## 57          19 0.147081592
## 58          20 0.154822728
## 59          22 0.170305001
## 60          30 0.232234092
## 61          34 0.263198638
## 62          20 0.154822728
## 63          34 0.263198638
## 64          13 0.100634773
## 65          29 0.224492956
## 66          42 0.325127729
## 67          34 0.263198638
## 68          28 0.216751819
## 69          22 0.170305001
## 70          30 0.232234092
## 71          10 0.077411364
## 72          23 0.178046137
## 73          19 0.147081592
## 74          17 0.131599319
## 75          27 0.209010683
## 76          53 0.410280229
## 77          36 0.278680910
## 78          30 0.232234092
## 79          16 0.123858182
## 80          38 0.294163183
## 81          28 0.216751819
## 82          48 0.371574547
## 83          63 0.487691593
## 84          37 0.286422047
## 85          19 0.147081592
## 86          28 0.216751819
## 87          38 0.294163183
## 88          30 0.232234092
## 89          24 0.185787274
## 90          24 0.185787274
## 91          42 0.325127729
## 92          41 0.317386592
## 93          28 0.216751819
## 94          54 0.418021366
## 95          26 0.201269546
## 96          36 0.278680910
## 97          23 0.178046137
## 98          46 0.356092274
## 99          43 0.332868865
## 100         68 0.526397275
## 101         45 0.348351138
## 102         30 0.232234092
## 103         47 0.363833411
## 104         62 0.479950457
## 105         41 0.317386592
## 106         61 0.472209320
## 107         40 0.309645456
## 108         38 0.294163183
## 109         45 0.348351138
## 110         46 0.356092274
## 111         45 0.348351138
## 112         48 0.371574547
## 113         57 0.441244775
## 114         51 0.394797956
## 115         54 0.418021366
## 116         41 0.317386592
## 117         33 0.255457501
## 118         53 0.410280229
## 119         69 0.534138412
## 120         33 0.255457501
## 121         41 0.317386592
## 122         43 0.332868865
## 123          3 0.023223409
## 124         79 0.611549776
## 125         61 0.472209320
## 126         23 0.178046137
## 127         46 0.356092274
## 128         42 0.325127729
## 129         33 0.255457501
## 130         34 0.263198638
## 131         61 0.472209320
## 132         55 0.425762502
## 133         59 0.456727048
## 134         41 0.317386592
## 135         61 0.472209320
## 136         36 0.278680910
## 137         45 0.348351138
## 138         60 0.464468184
## 139         57 0.441244775
## 140         33 0.255457501
## 141         31 0.239975228
## 142         44 0.340610002
## 143         37 0.286422047
## 144         52 0.402539093
## 145         38 0.294163183
## 146         41 0.317386592
## 147         51 0.394797956
## 148         37 0.286422047
## 149         42 0.325127729
## 150         35 0.270939774
## 151         51 0.394797956
## 152         28 0.216751819
## 153         69 0.534138412
## 154         29 0.224492956
## 155         49 0.379315684
## 156         35 0.270939774
## 157         52 0.402539093
## 158         47 0.363833411
## 159         41 0.317386592
## 160         34 0.263198638
## 161         34 0.263198638
## 162         34 0.263198638
## 163         39 0.301904320
## 164         49 0.379315684
## 165         29 0.224492956
## 166         62 0.479950457
## 167         56 0.433503638
## 168         35 0.270939774
## 169         56 0.433503638
## 170         35 0.270939774
## 171         71 0.549620684
## 172         48 0.371574547
## 173         51 0.394797956
## 174         44 0.340610002
## 175         30 0.232234092
## 176         59 0.456727048
## 177         70 0.541879548
## 178         73 0.565102957
## 179         47 0.363833411
## 180         32 0.247716365
## 181         49 0.379315684
## 182         34 0.263198638
## 183         54 0.418021366
## 184         26 0.201269546
## 185         32 0.247716365
## 186         56 0.433503638
## 187         70 0.541879548
## 188         50 0.387056820
## 189         38 0.294163183
## 190         50 0.387056820
## 191         30 0.232234092
## 192         41 0.317386592
## 193        128 0.990865459
## 194          5 0.038705682
## 195         78 0.603808639
## 196         69 0.534138412
## 197         51 0.394797956
## 198         47 0.363833411
## 199         32 0.247716365
## 200         61 0.472209320
## 201         82 0.634773185
## 202         54 0.418021366
## 203         32 0.247716365
## 204         47 0.363833411
## 205         34 0.263198638
## 206         44 0.340610002
## 207         40 0.309645456
## 208         76 0.588326366
## 209         26 0.201269546
## 210         67 0.518656139
## 211         40 0.309645456
## 212         55 0.425762502
## 213         46 0.356092274
## 214         43 0.332868865
## 215         43 0.332868865
## 216         34 0.263198638
## 217         49 0.379315684
## 218         33 0.255457501
## 219         41 0.317386592
## 220         39 0.301904320
## 221         64 0.495432730
## 222         29 0.224492956
## 223         50 0.387056820
## 224         56 0.433503638
## 225         44 0.340610002
## 226         54 0.418021366
## 227         37 0.286422047
## 228         37 0.286422047
## 229         29 0.224492956
## 230         36 0.278680910
## 231         62 0.479950457
## 232         34 0.263198638
## 233         84 0.650255458
## 234         52 0.402539093
## 235         59 0.456727048
## 236         36 0.278680910
## 237         31 0.239975228
## 238         47 0.363833411
## 239         44 0.340610002
## 240         47 0.363833411
## 241         26 0.201269546
## 242         93 0.719925685
## 243        347 2.686174330
## 244         26 0.201269546
## 245         44 0.340610002
## 246         37 0.286422047
## 247         56 0.433503638
## 248         28 0.216751819
## 249         29 0.224492956
## 250         27 0.209010683
## 251         28 0.216751819
## 252         30 0.232234092
## 253         27 0.209010683
## 254         41 0.317386592
## 255         26 0.201269546
## 256         35 0.270939774
## 257         24 0.185787274
## 258         35 0.270939774
## 259         23 0.178046137
## 260         46 0.356092274
## 261         67 0.518656139
## 262         28 0.216751819
## 263         31 0.239975228
## 264         14 0.108375910
## 265         53 0.410280229
## 266         34 0.263198638
## 267         19 0.147081592
## 268         39 0.301904320
## 269         32 0.247716365
## 270         22 0.170305001
## 271         34 0.263198638
## 272         39 0.301904320
## 273         35 0.270939774
## 274         31 0.239975228
## 275         49 0.379315684
## 276         16 0.123858182
## 277         59 0.456727048
## 278         31 0.239975228
## 279         19 0.147081592
## 280         24 0.185787274
## 281         14 0.108375910
## 282         38 0.294163183
## 283         39 0.301904320
## 284         35 0.270939774
## 285         36 0.278680910
## 286         20 0.154822728
## 287         20 0.154822728
## 288         25 0.193528410
## 289         21 0.162563864
## 290         23 0.178046137
## 291         22 0.170305001
## 292         41 0.317386592
## 293         30 0.232234092
## 294         17 0.131599319
## 295         62 0.479950457
## 296         24 0.185787274
## 297         29 0.224492956
## 298         18 0.139340455
## 299         41 0.317386592
## 300         37 0.286422047
## 301        607 4.698869794
## 302        199 1.540486143
## 303          4 0.030964546
## 304          4 0.030964546
## 305          2 0.015482273
## 306          4 0.030964546
## 307          4 0.030964546
## 308          4 0.030964546
## 309          9 0.069670228
## 310          4 0.030964546
## 311          5 0.038705682
## 312          6 0.046446818
## 313          8 0.061929091
## 314          9 0.069670228
## 315          7 0.054187955
## 316          2 0.015482273
## 317          2 0.015482273
## 318          6 0.046446818
## 319          5 0.038705682
## 320          2 0.015482273
## 321          2 0.015482273
## 322          4 0.030964546
## 323          4 0.030964546
## 324          4 0.030964546
## 325          6 0.046446818
## 326          2 0.015482273
## 327          2 0.015482273
## 328          2 0.015482273
## 329         10 0.077411364
## 330          4 0.030964546
## 331          8 0.061929091
## 332          2 0.015482273
## 333          4 0.030964546
## 334          3 0.023223409
## 335          4 0.030964546
## 336          4 0.030964546
## 337          2 0.015482273
## 338          2 0.015482273
## 339          2 0.015482273
## 340          2 0.015482273
## 341          4 0.030964546
## 342          4 0.030964546
## 343          6 0.046446818
## 344          2 0.015482273
## 345          6 0.046446818
## 346          2 0.015482273
## 347          2 0.015482273
## 348          2 0.015482273
## 349          4 0.030964546
## 350          2 0.015482273
## 351          2 0.015482273
## 352          2 0.015482273
## 353          2 0.015482273
## 354          2 0.015482273
## 355          2 0.015482273
## 356          2 0.015482273
## 357          2 0.015482273
## 358          2 0.015482273
## 372          7 0.054187955
## 400          4 0.030964546
## 401          5 0.038705682
## 403         10 0.077411364
## 404         10 0.077411364
## 405          1 0.007741136
## 406          9 0.069670228
## 408          3 0.023223409
## 409          7 0.054187955
## 688          3 0.023223409
## 1320         2 0.015482273
## 1323         1 0.007741136
## 1325         2 0.015482273
## 1328         1 0.007741136
## 1528         4 0.030964546
## 1541         1 0.007741136
## 2011         9 0.069670228
## 2142         3 0.023223409
## 2143         1 0.007741136
## 2144         2 0.015482273
## 2190         2 0.015482273
## 2261         3 0.023223409
## 2269         1 0.007741136
## 3390         2 0.015482273
## 3732         2 0.015482273
## 4004         2 0.015482273
## 4038         3 0.023223409
## 4091         2 0.015482273
## 4094         1 0.007741136
## 5165         2 0.015482273
## 6120         1 0.007741136
## 6185         1 0.007741136
## 7160         2 0.015482273
## 8860         2 0.015482273
SuperstoreSalesTraining_freq <- SuperstoreSalesTraining $Category
cbind(frequency = table(SuperstoreSalesTraining_freq),
      percentage = prop.table(table(SuperstoreSalesTraining_freq)) * 100)
##    frequency percentage
## 1        845   6.541260
## 2       1374  10.636321
## 3        586   4.536306
## 4       1915  14.824276
## 5       1007   7.795324
## 6        524   4.056355
## 7       1196   9.258399
## 8        566   4.381483
## 9       1176   9.103576
## 10      1359  10.520204
## 11       289   2.237188
## 12       139   1.076018
## 13       661   5.116891
## 14       431   3.336430
## 15       276   2.136554
## 16       214   1.656603
## 17       360   2.786809
## 2.Measures of Central Tendency ----
## calculating mode
SuperstoreSalesTraining_Item_mode <- names(table(SuperstoreSalesTraining$Item))[
  which(table(SuperstoreSalesTraining$Item) == max(table(SuperstoreSalesTraining$Item)))
]
print(SuperstoreSalesTraining_Item_mode)
## [1] "301"
SuperstoreSalesTraining_Category_mode <- names(table(SuperstoreSalesTraining$Category))[
  which(table(SuperstoreSalesTraining$Category) == max(table(SuperstoreSalesTraining$Category)))
]
print(SuperstoreSalesTraining_Category_mode)
## [1] "4"
## 3. Measures of Distribution----

summary(SuperstoreSalesTraining)
##       Row             Order           Discount         UnitPrice      
##  Min.   :     1   Min.   :     3   Min.   :0.00000   Min.   :   1.00  
##  1st Qu.:  3176   1st Qu.: 29318   1st Qu.:0.02000   1st Qu.:   6.00  
##  Median :  6448   Median : 85834   Median :0.05000   Median :  21.00  
##  Mean   :  6578   Mean   : 60004   Mean   :0.05728   Mean   :  89.51  
##  3rd Qu.:  9686   3rd Qu.: 88701   3rd Qu.:0.08000   3rd Qu.:  86.00  
##  Max.   :122011   Max.   :912011   Max.   :0.95000   Max.   :6783.00  
##  OrderQuantity       Sales            Profit          ShippingCost   
##  Min.   :  1.0   Min.   :     1   Min.   : -3892.6   Min.   :  0.00  
##  1st Qu.:  7.0   1st Qu.:    83   1st Qu.:    26.7   1st Qu.:  3.00  
##  Median : 15.0   Median :   309   Median :   123.0   Median :  6.00  
##  Mean   : 24.7   Mean   :  1698   Mean   :   845.3   Mean   : 12.82  
##  3rd Qu.: 36.0   3rd Qu.:  1263   3rd Qu.:   594.0   3rd Qu.: 14.00  
##  Max.   :176.0   Max.   :201124   Max.   :120116.9   Max.   :165.00  
##  ProductBaseMargin    Category           Item         Customer_ID   
##  Min.   : 0.0360   Min.   : 1.000   Min.   :   1.0   Min.   :    1  
##  1st Qu.: 0.3800   1st Qu.: 4.000   1st Qu.: 106.0   1st Qu.:  882  
##  Median : 0.5200   Median : 7.000   Median : 177.0   Median : 1742  
##  Mean   : 0.5021   Mean   : 7.077   Mean   : 184.4   Mean   : 1813  
##  3rd Qu.: 0.5900   3rd Qu.:10.000   3rd Qu.: 243.0   3rd Qu.: 2616  
##  Max.   :16.0000   Max.   :17.000   Max.   :8860.0   Max.   :32011
## Measure the standard deviation

sapply(SuperstoreSalesTraining[, 1:12], sd)
##               Row             Order          Discount         UnitPrice 
##      5.351417e+03      3.990588e+04      8.789348e-02      2.917522e+02 
##     OrderQuantity             Sales            Profit      ShippingCost 
##      2.564518e+01      4.768233e+03      2.634376e+03      1.723208e+01 
## ProductBaseMargin          Category              Item       Customer_ID 
##      2.043335e-01      4.286782e+00      2.374661e+02      1.608847e+03
## Measure the variance
sapply(SuperstoreSalesTraining[, 1:12], var)
##               Row             Order          Discount         UnitPrice 
##      2.863767e+07      1.592479e+09      7.725263e-03      8.511933e+04 
##     OrderQuantity             Sales            Profit      ShippingCost 
##      6.576753e+02      2.273605e+07      6.939934e+06      2.969445e+02 
## ProductBaseMargin          Category              Item       Customer_ID 
##      4.175217e-02      1.837650e+01      5.639013e+04      2.588389e+06
##Measure the skewness
sapply(SuperstoreSalesTraining[, 1:12], skewness, type = 2)
##               Row             Order          Discount         UnitPrice 
##        10.0128455         6.0702362         8.7316585        14.1019860 
##     OrderQuantity             Sales            Profit      ShippingCost 
##         1.9709778        11.2278010        15.8563982         2.5614867 
## ProductBaseMargin          Category              Item       Customer_ID 
##        33.7255310         0.5145462        19.9125066         7.7411789
## 4. Measures of Relationship ----
##  Measure the covariance

SuperstoreSalesTraining_cov <- cov(SuperstoreSalesTraining[, 1:12])
View(SuperstoreSalesTraining_cov)

## Measure the correlation
SuperstoreSalesTraining_cor <- cor(SuperstoreSalesTraining[, 1:12])
View(SuperstoreSalesTraining_cor)
## 5. Inferential Statistics ----
##  Performing ANOVA
SuperstoreSalesTraining_oneway_anova <- aov(Sales ~ Category, data = SuperstoreSalesTraining)
summary(SuperstoreSalesTraining_oneway_anova)
##                Df    Sum Sq  Mean Sq F value Pr(>F)  
## Category        1 8.575e+07 85750114   3.772 0.0521 .
## Residuals   12916 2.936e+11 22731170                 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 6. Basic Visualizations----
# 6.1 Univariate Plots----
#Histograms
hist(table(SuperstoreSalesTraining$Item), main = "",
        xlab = "Item", ylab = "Count", col = "Blue")

hist(table(SuperstoreSalesTraining$Category), main = "",
     xlab = "Category", ylab = "Count", col = "Blue")

hist(table(SuperstoreSalesTraining$Discount), main = "",
     xlab = "Discount", ylab = "Count", col = "Blue")

hist(table(SuperstoreSalesTraining$UnitPrice), main = "",
     xlab = "Unit Price", ylab = "Count", col = "Blue")

hist(table(SuperstoreSalesTraining$Sales), main = "",
     xlab = "sales", ylab = "Count", col = "Blue")

hist(table(SuperstoreSalesTraining$Profit), main = "",
     xlab = "Profit", ylab = "Count", col = "Blue")

## Create Box Plots
boxplot(table(SuperstoreSalesTraining$Item), main = "",
     xlab = "Item", ylab = "Count", col = "Blue")

 boxplot(table(SuperstoreSalesTraining$Category), main = "",
     xlab = "Category", ylab = "Count", col = "Blue")

boxplot(table(SuperstoreSalesTraining$Discount), main = "",
     xlab = "Discount", ylab = "Count", col = "Blue")

boxplot(table(SuperstoreSalesTraining$UnitPrice), main = "",
     xlab = "Unit Price", ylab = "Count", col = "Blue")

boxplot(table(SuperstoreSalesTraining$Sales), main = "",
     xlab = "sales", ylab = "Count", col = "Blue")

boxplot(table(SuperstoreSalesTraining$Profit), main = "",
     xlab = "Profit", ylab = "Count", col = "Blue")

## Bar plot showing the values of the categorical
barplot(table(SuperstoreSalesTraining[, 10]), main = names(SuperstoreSalesTraining)[10])

## Missingness Map to Identify Missing Data
missmap(SuperstoreSalesTraining, col = c("purple", "pink"), legend = TRUE)
## Warning: Unknown or uninitialised column: `arguments`.
## Unknown or uninitialised column: `arguments`.

## Warning: Unknown or uninitialised column: `imputations`.

## 6.2 Multivariate Plots----
##Correlation Plot
corrplot(cor(SuperstoreSalesTraining[, 1:12], method = "pearson"))

## ggcorrplot
ggcorrplot(cor(SuperstoreSalesTraining[, 1:12], method = "pearson"))

## Scatter Plot
ggplot(SuperstoreSalesTraining, aes(x = Category, y = Sales, color = Sales)) +
  geom_point() +
  geom_smooth(method = lm)
## `geom_smooth()` using formula = 'y ~ x'

## Warning: The following aesthetics were dropped during statistical transformation: colour
## ℹ This can happen when ggplot fails to infer the correct grouping structure in
##   the data.
## ℹ Did you forget to specify a `group` aesthetic or to convert a numerical
##   variable into a factor?