#Input data
 Page <- c(500, 700, 800, 600, 400, 500, 600, 800)
 Price <- c(84, 75, 99, 72, 69, 81, 63, 93)
#Membuat Scatterplot
 plot (x = Page, y = Price,
 main = "Scatterplot Page vs Price",
 xlab = "Page",
 ylab = "Price (dollar)")

 #Koefisien Korelasi
 cor(Page, Price, method = "pearson")
## [1] 0.6138789
 #Matriks Korelasi
 df <- data.frame(Page, Price)
 korelasi <- cor(df)
 korelasi
##            Page     Price
## Page  1.0000000 0.6138789
## Price 0.6138789 1.0000000
 #install.packages("corrplot")
 library(corrplot)
## Warning: package 'corrplot' was built under R version 4.4.2
## corrplot 0.95 loaded
 corrplot(corr = korelasi, method = "number", type = "upper")

#Uji Signifikansi Koefisien Korelasi
 #Hipotesis H0: rho = 0 vs H1: rho ≠ 0
 cor.test(x = Page, y = Price, alternative = "two.sided",
         method = "pearson",
         exact = NULL, conf.level = 0.95)
## 
##  Pearson's product-moment correlation
## 
## data:  Page and Price
## t = 1.9049, df = 6, p-value = 0.1055
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.1600131  0.9204012
## sample estimates:
##       cor 
## 0.6138789

Signifikansi korelasi: Nilai 𝑝=0.1055, yang lebih besar dari tingkat signifikansi umum (α=0.05). Artinya, hubungan ini tidak signifikan secara statistik, sehingga kita tidak cukup bukti untuk menyatakan ada hubungan linear yang nyata antara jumlah halaman dan harga buku.