# Clear the workspace
rm(list = ls()) # Clear environment
gc() # Clear unused memory
## used (Mb) gc trigger (Mb) max used (Mb)
## Ncells 521432 27.9 1159612 62 660385 35.3
## Vcells 947692 7.3 8388608 64 1769723 13.6
cat("\f") # Clear the console
Correlation is a statistical measure that indicates the extent to which two or more variables fluctuate in relation to each other.
A positive correlation indicates the extent to which those variables increase or decrease in parallel.
A negative correlation indicates the extent to which one variable increases as the other decreases.
Covariance in statistics measures the extent to which two variables vary linearly. It reveals whether two variables move in the same or opposite directions.
A positive covariance means asset returns move together.
A negative covariance means they move inversely.
library(readr)
setwd("C:/Users/LENOVO/Downloads/Data Analytics/Week_12")
#Load the data
Prod = read.csv("products.csv")
Invent = read.csv("inventory.csv")
library(visdat)
## Warning: package 'visdat' was built under R version 4.3.2
vis_dat(Prod)
vis_dat(Invent)
#Merge Chapter and Dialogue
Merged = merge(x = Prod,
y = Invent,
by = c("Product_ID"))
vis_dat(Merged)
library(stargazer)
##
## Please cite as:
## Hlavac, Marek (2022). stargazer: Well-Formatted Regression and Summary Statistics Tables.
## R package version 5.2.3. https://CRAN.R-project.org/package=stargazer
stargazer(Merged,
type = "text",
title = "Summary")
##
## Summary
## ===========================================
## Statistic N Mean St. Dev. Min Max
## -------------------------------------------
## Product_ID 1,593 18.073 10.064 1 35
## Store_ID 1,593 25.326 14.478 1 50
## Stock_On_Hand 1,593 18.670 18.998 0 139
## -------------------------------------------
summary(Merged)
## Product_ID Product_Name Product_Category Product_Cost
## Min. : 1.00 Length:1593 Length:1593 Length:1593
## 1st Qu.: 9.00 Class :character Class :character Class :character
## Median :18.00 Mode :character Mode :character Mode :character
## Mean :18.07
## 3rd Qu.:27.00
## Max. :35.00
## Product_Price Store_ID Stock_On_Hand
## Length:1593 Min. : 1.00 Min. : 0.00
## Class :character 1st Qu.:13.00 1st Qu.: 6.00
## Mode :character Median :25.00 Median : 13.00
## Mean :25.33 Mean : 18.67
## 3rd Qu.:38.00 3rd Qu.: 24.00
## Max. :50.00 Max. :139.00
correlation = cor(Merged$Store_ID,
Merged$Stock_On_Hand,
use = "complete.obs")
correlation
## [1] 0.0704017
covariance = cov(Merged$Store_ID,
Merged$Stock_On_Hand,
use = "complete.obs")
covariance
## [1] 19.3633