# Load library
library(ggplot2)
library(dplyr)
library(tidyr)
library(ggpmisc)
tlkm<-read.csv("C:/Users/dian2/OneDrive/Documents/SEM 6/BINTEL/Data Historis TLKM.csv")
excl<-read.csv("C:/Users/dian2/OneDrive/Documents/SEM 6/BINTEL/Data Historis EXCL.csv")
isat<-read.csv("C:/Users/dian2/OneDrive/Documents/SEM 6/BINTEL/Data Historis ISAT.csv")
datatlkm<-data.frame(Time=as.Date(tlkm$Tanggal, format="%d/%m/%Y"),Price=
tlkm$Terakhir)
dataexcl<-data.frame(Time=as.Date(excl$Tanggal, format="%d/%m/%Y"),Price=
excl$Terakhir)
dataisat<-data.frame(Time=as.Date(isat$Tanggal, format="%d/%m/%Y"),Price= isat$Terakhir)
tlkm_plot<-ggplot(datatlkm,aes(x=Time,y=Price))+geom_line()
tlkm_plot
tlkm_plot+scale_x_date(date_labels="%b %y",date_breaks="2 months")+
theme_minimal()+
theme(axis.text.x=element_text(angle=50,hjust=1))+
geom_vline(xintercept = as.Date(c("2022-01-01", "2023-01-01", "2024-01-01")),
linetype = "dashed", color = "red") +
stat_peaks(geom="point",span=15,color="Steelblue",size=2)+
stat_peaks(geom="label",span=15,color="Steelblue",angle=0,
hjust=1,x.label.fmt="%d/%m/%y")+
stat_peaks(geom="rug",span=15,color="blue",sides="b")+
labs(title = "Time Series TLKM",
x = "Tanggal", y = "Price", color = "Kategori") +
theme(legend.position = "bottom")
excl_plot<-ggplot(dataexcl,aes(x=Time,y=Price))+geom_line()
excl_plot
excl_plot+scale_x_date(date_labels="%b %y",date_breaks="2 months")+
theme_minimal()+
theme(axis.text.x=element_text(angle=50,hjust=1))+
geom_vline(xintercept = as.Date(c("2022-01-01", "2023-01-01", "2024-01-01")),
linetype = "dashed", color = "red")+
stat_peaks(geom="point",span=15,color="Steelblue",size=2)+
stat_peaks(geom="label",span=15,color="Steelblue",angle=0,
hjust=1,x.label.fmt="%d/%m/%y")+
stat_peaks(geom="rug",span=15,color="blue",sides="b")+
labs(title = "Time Series EXCL",
x = "Tanggal", y = "Price", color = "Kategori") +
theme(legend.position = "bottom")
isat_plot<-ggplot(dataisat,aes(x=Time,y=Price))+geom_line()
isat_plot
isat_plot+scale_x_date(date_labels="%b %y",date_breaks="2 months")+
theme_minimal()+
theme(axis.text.x=element_text(angle=50,hjust=1))+
geom_vline(xintercept = as.Date(c("2022-01-01", "2023-01-01", "2024-01-01")),
linetype = "dashed", color = "red")+
stat_peaks(geom="point",span=15,color="Steelblue",size=2)+
stat_peaks(geom="label",span=15,color="Steelblue",angle=0,
hjust=1,x.label.fmt="%d/%m/%y")+
stat_peaks(geom="rug",span=15,color="blue",sides="b")+
labs(title = "Time Series ISAT",
x = "Tanggal", y = "Price", color = "Kategori") +
theme(legend.position = "bottom")
telkom=datatlkm$Price
xl=dataexcl$Price
indosat=dataisat$Price
combined.data=data.frame(telkom,xl,indosat)
combined.timeseries=ts(combined.data,start=c(2020,8), frequency=12*31)
plot(combined.timeseries)
Grafik diatas menunjukkan pergerakan harga saham Telkom, XL, dan Indosat dari tahun 2020 sampai 2022. Saham Telkom terlihat naik secara stabil dari awal 2020 hingga awal 2022. Saham XL lebih fluktuatif, naik-turun sepanjang waktu, tapi sempat meningkat tajam di akhir 2021. Sementara itu, saham Indosat awalnya stabil, lalu tiba-tiba melonjak drastis di pertengahan 2021—kemungkinan karena ada peristiwa besar seperti merger atau akuisisi. Secara keseluruhan, Telkom cenderung stabil, XL cukup bergejolak, dan Indosat menunjukkan lonjakan mendadak.
boxplot(datatlkm$Price,dataexcl$Price,dataisat$Price)
Secara keseluruhan, boxplot diatas menunjukkan variasi yang signifikan dalam harga dan adanya beberapa harga ekstrem yang mempengaruhi distribusi. Telkom menunjukkan harga yang lebih stabil, sementara XL dan Indosat menunjukkan fluktuasi harga yang lebih tinggi. XL cenderung memiliki harga yang lebih rendah, sedangkan Indosat memiliki lebih banyak variasi harga, baik di sisi atas maupun bawah. Outliers di XL dan Indosat menunjukkan pergerakan harga yang mungkin terkait dengan kondisi pasar tertentu, misalnya reaksi terhadap berita industri atau laporan keuangan.