hypotheses

Null hypotheses: There is no relationship between time spent (minutes) in the shop and number of drinks purchased.

Alternate hypotheses: There is a relationship between time spent (minutes) in the shop and number of drinks purchased.

Result

A Spearman correlation was conducted to assess the relationship between Minutes and Drinks (n = 461). There was a statistically significant correlation between Mintues (M = 29.89, SD = 18.63) and Drinks (M = 3.00, SD = 1.95).The correlation was Positive and strong rho=0.92, p < .001.As time spent (minutes) in the shop increases, number of drinks purchased increases.Thus the alternate hypotheses is supported and there is strong relationship between time spent (minutes) in the shop and number of drinks purchased.

#install.packages("readxl")
library(readxl)
dataset <- read_excel("~/Downloads/A5RQ1.xlsx")
#install.packages("psych")
library(psych)
describe(dataset[, c("Minutes", "Drinks")])
##         vars   n  mean    sd median trimmed   mad min   max range skew kurtosis
## Minutes    1 461 29.89 18.63   24.4   26.99 15.12  10 154.2 144.2 1.79     5.20
## Drinks     2 461  3.00  1.95    3.0    2.75  1.48   0  17.0  17.0 1.78     6.46
##           se
## Minutes 0.87
## Drinks  0.09
hist(dataset$Minutes,
     main = "Histogram of Minutes",
     xlab = "Value",
     ylab = "Frequency",
     col = "lightblue",
     border = "black",
     breaks = 20)

hist(dataset$Drinks,
     main = "Histogram of Drinks",
     xlab = "Value",
     ylab = "Frequency",
     col = "lightgreen",
     border = "black",
     breaks = 20)

shapiro.test(dataset$Minutes)
## 
##  Shapiro-Wilk normality test
## 
## data:  dataset$Minutes
## W = 0.84706, p-value < 2.2e-16
shapiro.test(dataset$Drinks)
## 
##  Shapiro-Wilk normality test
## 
## data:  dataset$Drinks
## W = 0.85487, p-value < 2.2e-16
#install.packages("ggplot2")
#install.packages("ggpubr")
library(ggplot2)
## 
## Attaching package: 'ggplot2'
## The following objects are masked from 'package:psych':
## 
##     %+%, alpha
library(ggpubr)
ggscatter(dataset, x = "Minutes", y = "Drinks",
          add = "reg.line",
          conf.int = TRUE,
          cor.coef = TRUE,
          cor.method = "spearman",
          xlab = "Variable Minutes", ylab = "Variable Drinks")

cor.test(dataset$Minutes, dataset$Drinks, method = "spearman")
## Warning in cor.test.default(dataset$Minutes, dataset$Drinks, method =
## "spearman"): Cannot compute exact p-value with ties
## 
##  Spearman's rank correlation rho
## 
## data:  dataset$Minutes and dataset$Drinks
## S = 1305608, p-value < 2.2e-16
## alternative hypothesis: true rho is not equal to 0
## sample estimates:
##       rho 
## 0.9200417