Pastikan kalian sudah memanggil library yang dibutuhkan dan meng-import datasetnya yaa Disini saya menggunakan Dataset Close Price dari Saham Healthcare yaitu KLBF, SIDO, dan MIKA selama 3 tahun terakhir
dataklbf$Stock <- "KLBF"
datasido$Stock <- "SIDO"
datamika$Stock <- "MIKA"
data_all <- rbind(
dataklbf[,c("Time","Price","Stock")],
datasido[,c("Time","Price","Stock")],
datamika[,c("Time","Price","Stock")]
)
ggplot(data_all, aes(x = Time, y = Price, color = Stock)) +
geom_line(linewidth = 1) +
labs(title = "Healthcare Close Price Comparison",
x = "Date", y = "Price") +
geom_vline(xintercept = as.Date("2023-01-01"),
linetype = 2, color = "pink",
linewidth = 0.75) +
geom_vline(xintercept = as.Date("2024-01-01"),
linetype = 2, color = "green4",
linewidth = 0.75) +
geom_vline(xintercept = as.Date("2025-01-01"),
linetype = 2, color = "coral",
linewidth = 0.75) +
geom_vline(xintercept = as.Date("2026-01-01"),
linetype = 2, color = "purple3",
linewidth = 0.75) +
scale_x_date(date_labels = "%b %Y", date_breaks = "1 month") +
theme_minimal() +
theme(axis.text.x = element_text(angle = 45, hjust = 1))
Dapat dilihat dari plot di atas, bahwa close price paling tinggi yaitu MIKA, disusul KLBF, dan yang paling rendah adalah SIDO