The following analysis for July, 2020 is made acccording to PTF/SMF data from Energy Exchange Istanbul(EXIST) page.
knitr::opts_chunk$set(echo = TRUE)
library(readxl)
library(dplyr)
library(ggplot2)
library(lubridate)
library(tidyr)
Dataset
ptfsmf <- read_excel('ptf-smf-2.xls')
Dataset
# Arrangement of the names of the positive and negative imbalance columns
colnames(ptfsmf)[4] = "PDF"
colnames(ptfsmf)[5] = "NDF"
# Converting the date and time to POSIX format
ptfsmf <- ptfsmf %>% mutate(Tarih_Yeni =
as.POSIXct(ptfsmf$Tarih,format="%d.%m.%y %H:%M", "GMT")) %>%
select(Tarih_Yeni, PTF, SMF, PDF, NDF) %>%
rename(Tarih = Tarih_Yeni)
# Converting the remaining columns to numeric class
ptfsmf[,c(2:5)] <- lapply(ptfsmf[,c(2:5)],
function(x) as.numeric(gsub(",", ".", gsub("\\.", "", x))))
weekly_analysis <- ptfsmf %>%
select(Tarih,PTF,SMF,PDF,NDF) %>%
mutate(Week=as.factor(week(Tarih)))%>%
pivot_longer(cols = c(PTF,SMF,PDF,NDF),names_to = 'names',values_to='values')%>%
group_by(Week,names)%>%
summarise(sum_price=sum(values),mean_price=mean(values),max_price = max(values),min_price=min(values),.groups = 'drop')%>%
transform(Week=as.numeric(Week))
weekly_analysis2<-weekly_analysis %>% filter(names=="PTF" | names== "SMF")
ggplot(weekly_analysis2,aes(x=Week,y=sum_price)) + geom_bar(stat="identity",aes(fill=names))
hourly_analysis <- ptfsmf %>%
select(Tarih,PTF,SMF,PDF,NDF) %>%
mutate(Hour=as.factor(hour(Tarih)))%>%
pivot_longer(cols = c(PTF,SMF,PDF,NDF),names_to = 'names',values_to='values')%>%
group_by(Hour,names)%>%
summarise(sum_price=sum(values),mean_price=mean(values),max_price = max(values),min_price=min(values),.groups = 'drop')%>%
transform(Hour=as.numeric(Hour))
hourly_analysis2<-hourly_analysis %>% filter(names=="PTF" | names== "SMF")
ggplot(hourly_analysis2, aes(x=Hour, y=mean_price, fill=names)) +
geom_bar(stat="identity", position="dodge")+labs(x="Hours of Per Days on July",y="Mean Prices")+ scale_x_discrete(limits=c(1:24))+ggtitle("Comparing Mean Prices per PTF/SMF across continents Hours of per Days on July")
daily_analysis <- ptfsmf %>%
select(Tarih,PTF,SMF,PDF,NDF) %>%
mutate(Day=as.factor(day(Tarih)))%>%
pivot_longer(cols = c(PTF,SMF,PDF,NDF),names_to = 'names',values_to='values')%>%
group_by(Day,names)%>%
summarise(sum_price=sum(values),mean_price=mean(values),max_price = max(values),min_price=min(values),.groups = 'drop')%>%
transform(Day=as.numeric(Day))
daily_analysis2<-daily_analysis %>% filter(names=="PTF" | names== "SMF")
ggplot(daily_analysis2, aes(x=Day, y=max_price, color=names)) +
geom_line() +geom_point()+
theme_minimal() +
labs(x = "nth Day",
y = "Max Prices") +
scale_x_discrete(limits=c(1:31)) +
theme(axis.text.x = element_text(angle = 45), legend.position = "top")
ggplot(daily_analysis2, aes(x=Day, y=min_price, color=names)) +
geom_point() +
theme_minimal() +
labs(x = "nth Day",
y = "Min Prices") +scale_x_discrete(limits=c(1:31))+
theme(axis.text.x = element_text(angle = 45), legend.position = "top")