Pendahuluan
Dalam analisis data, hubungan antar variabel (bivariat) penting untuk
memahami bagaimana satu variabel memengaruhi variabel lainnya. Pada
laporan ini digunakan dataset diamonds dari package ggplot2. Fokus
analisis adalah hubungan antara variabel kontinu yaitu Carat (berat
berlian) dan Price (harga berlian)
Visualisasi Data
- Scatter Plot: Carat vs Price
Dalam analisis data, hubungan antar variabel (bivariat) penting untuk
memahami bagaimana satu variabel memengaruhi variabel lainnya. Pada
laporan ini digunakan dataset diamonds dari package ggplot2. Fokus
analisis adalah hubungan antara variabel kontinu yaitu Carat (berat
berlian) dan Price (harga berlian)
Visualisasi Data
- Scatter Plot: Carat vs Price
Visualisasi Data
- Scatter Plot: Carat vs Price
- Scatter Plot: Carat vs Price
interpretasi : Terlihat pola hubungan positif antara berat dan
harga. Semakin besar berat berlian, semakin tinggi harga yang
ditawarkan. Namun, kenaikan harga tidak sepenuhnya linear karena
terdapat variasi harga pada berat yang sama.
- Scatter Plot dengan Garis Regresi
ggplot(diamonds, aes(x = carat, y = price)) +
geom_point(alpha = 0.2, color = "skyblue") +
geom_smooth(method = "lm", color = "blue", se = FALSE) +
labs(
title = "Trend Linear Berat terhadap Harga",
x = "Berat Berlian (Carat)",
y = "Harga (USD)"
) +
theme_minimal(base_size = 14)
## `geom_smooth()` using formula = 'y ~ x'
- Scatter Plot dengan Garis Regresi
ggplot(diamonds, aes(x = carat, y = price)) +
geom_point(alpha = 0.2, color = "skyblue") +
geom_smooth(method = "lm", color = "blue", se = FALSE) +
labs(
title = "Trend Linear Berat terhadap Harga",
x = "Berat Berlian (Carat)",
y = "Harga (USD)"
) +
theme_minimal(base_size = 14)
## `geom_smooth()` using formula = 'y ~ x'
ggplot(diamonds, aes(x = carat, y = price)) +
geom_point(alpha = 0.2, color = "skyblue") +
geom_smooth(method = "lm", color = "blue", se = FALSE) +
labs(
title = "Trend Linear Berat terhadap Harga",
x = "Berat Berlian (Carat)",
y = "Harga (USD)"
) +
theme_minimal(base_size = 14)## `geom_smooth()` using formula = 'y ~ x'
interpretasi : Garis regresi menunjukkan adanya tren
peningkatan harga seiring bertambahnya berat berlian. Hal ini memperkuat
bahwa berat merupakan faktor utama dalam menentukan harga, meskipun
faktor lain seperti kualitas potongan dan warna juga dapat memengaruhi
harga.
- Hubungan Table dan Harga Berlian
ggplot(diamonds, aes(x = table, y = price)) +
geom_point(alpha = 0.2, color = "#2C7FB8") +
geom_smooth(method = "lm", se = FALSE, color = "blue", size = 1) +
labs(
title = "Hubungan Table dan Harga Berlian",
x = "Table (Ukuran Permukaan Atas)",
y = "Price (Harga)"
) +
theme_minimal()
## Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
## ℹ Please use `linewidth` instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
## `geom_smooth()` using formula = 'y ~ x'
- Hubungan Table dan Harga Berlian
ggplot(diamonds, aes(x = table, y = price)) +
geom_point(alpha = 0.2, color = "#2C7FB8") +
geom_smooth(method = "lm", se = FALSE, color = "blue", size = 1) +
labs(
title = "Hubungan Table dan Harga Berlian",
x = "Table (Ukuran Permukaan Atas)",
y = "Price (Harga)"
) +
theme_minimal()
## Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
## ℹ Please use `linewidth` instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
## `geom_smooth()` using formula = 'y ~ x'
ggplot(diamonds, aes(x = table, y = price)) +
geom_point(alpha = 0.2, color = "#2C7FB8") +
geom_smooth(method = "lm", se = FALSE, color = "blue", size = 1) +
labs(
title = "Hubungan Table dan Harga Berlian",
x = "Table (Ukuran Permukaan Atas)",
y = "Price (Harga)"
) +
theme_minimal()## Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
## ℹ Please use `linewidth` instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.## `geom_smooth()` using formula = 'y ~ x'