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 Hal Buku vs Harga Buku",
xlab="Jumlah Halaman (Hal)",
ylab="Harga Buku (Dollar)")
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)
## 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
Dengan p-value sebesar 0.1055 yang lebih besar dari 0.05, hipotesis nol tidak dapat ditolak. Hal ini menunjukkan bahwa tidak terdapat bukti yang cukup untuk menyatakan adanya korelasi signifikan antara jumlah halaman dan harga buku.