install.packages("ggpubr")

library(readxl)
library(ggpubr)
  
data <- read_excel("C:/Users/hp/Desktop/digital Forensics/AA 5221/Asignment_5/A5Q1(Sheet1).xls")
View(data)

ggscatter(
  data,
  x = "age",
  y = "education",
  add = "reg.line",
  xlab = "Age",
  ylab = "Education"
)

# The relationship is linear.
# The relationship is positive.
# There are no outliers.

mean(data$age)
sd(data$age)
median(data$age)

mean(data$education)
sd(data$education)
median(data$education)

hist(data$age)
hist(data$education)

# Variable 1: Age
# The variable looks normally distributed.
# The data is symmetrical.
# The data has a proper bell curve.

# Variable 2: Education
# The variable looks normally distributed.
# The data is symmetrical.
# The data has a proper bell curve.

shapiro.test(data$age)
shapiro.test(data$education)

# Variable 1: Age
# The variable is normally distributed (p = .5581).

# Variable 2: Education
# The variable is normally distributed (p = .4385).

cor.test(data$age, data$education, method = "pearson")

# A Pearson correlation was conducted to test the relationship between age and education.

# There was a statistically significant relationship between the two variables,
# r(148) = .52, p < .001.

# The relationship was positive and moderate.

# As age increased, education increased.