page <- c(500, 700, 800, 600, 400, 500, 600, 800)
price <- c(84, 75, 99, 72, 69, 81, 63, 93)
plot(x=page, y=price,
     main="Scatterplot Halaman Terhadap Harga Buku",
     xlab="Jumlah Halaman (hlm)",
     ylab="Harga Buku ($)")

cor(page, price, method = "pearson")
## [1] 0.6138789
data_buku <- data.frame(page, price)
 korelasi <- cor(data_buku)
korelasi
##            page     price
## page  1.0000000 0.6138789
## price 0.6138789 1.0000000
 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

Nilai p (p-value = 0.1055): Karena nilai p > 0.05, maka tak tolak hipotesis nol dan dapat disimpulkan bahwa belum cukup bukti untuk menunjukkan bahwa ada korelasi yang signifikan antara jumlah halaman dan harga buku