September 2020’s Electricity Prices

Importing Necessary Packages

In this study dplyr package is used for data manipulation, ggplt2 package is used for creating plots and visuals and lubridate package is used to make it easier to work with dates and times.

library(dplyr)
library(ggplot2)
library(lubridate)
library(readxl)

Importing Dataset and Making Some Adjustments on It

  • Electricity dataset imported with using read_excel function.
  • 3 new columns added to dataset which are; Day1, Hour1 and WD, with using as_date, hour and weekdays functions, respectively.
    • Day1: Shows the day of the month (1,15,26 etc.)
    • Hour1:Shows the hour of the day (0,13,21 etc.)
    • WD: Shows the name of the day (Monday, Friday etc.)
  • With glimpse function updated/new created dataset quickly checked.
Elektrik <- read_excel("C:/Users/kamiu/Desktop/Elektrik.xlsx")
y <- Elektrik %>% mutate(Day1 = as_date(Tarih)) %>% mutate(Hour1 = hour(Tarih)) %>% mutate(WD = weekdays(Tarih))
y %>% glimpse()
## Rows: 720
## Columns: 9
## $ Tarih                                 <dttm> 2020-09-01 00:00:00, 2020-09...
## $ `PTF/MCP`                             <dbl> 302.39, 300.25, 292.64, 290.0...
## $ `SMF/SMP`                             <dbl> 332.39, 325.25, 317.64, 320.0...
## $ `Pozitif Dengesizlik Fiyati (TL/MWh)` <dbl> 293.32, 291.24, 283.86, 281.3...
## $ `Negatif Dengesizlik Fiyati (TL/MWh)` <dbl> 342.36, 335.01, 327.17, 329.6...
## $ `SMF Yön`                             <chr> "Enerji Açigi", "Enerji Açigi...
## $ Day1                                  <date> 2020-09-01, 2020-09-01, 2020...
## $ Hour1                                 <int> 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,...
## $ WD                                    <chr> "Tuesday", "Tuesday", "Tuesda...
  • Colmun names updated with rename function, and this updated dataset named v1
v1 = y %>% rename('Imbalance Price - Positive(TL/MWh)' = `Pozitif Dengesizlik Fiyatı (TL/MWh)`, 'Imbalance Price - Negative(TL/MWh)' = `Negatif Dengesizlik Fiyatı (TL/MWh)`,Date_Time = Tarih, JDate=Day1,JTime=Hour1,JDay= WD, 'Energy Deficit_Surplus' = `SMF Yön`, 'Market Clearing Price'=`PTF/MCP`, 'System Marginal Price'=`SMF/SMP` )
  • Energy balance colmun added to v1 dataset, which shows us when energy deficit occured, when energy surplus occured and when the energy is balanced.
  • And also isWeekeend column added to dataset to use in further analysis.
  • After each operation, new datasets created, reason of this is to reduce the effect of faulty operations
v2 = v1 %>% mutate( "Energy Balance"  = ifelse(`Market Clearing Price` > `System Marginal Price`, "Energy Surplus", ifelse(`Market Clearing Price` == `System Marginal Price`,"Balanced","Energy Deficit")))

v3 = v2%>%mutate("isWeekend"= ifelse(JDay== 'Monday','No',ifelse(JDay == 'Tuesday','No',ifelse(JDay == 'Wednesday','No',ifelse(JDay == 'Thursday','No',ifelse(JDay == 'Friday','No',ifelse(JDay == 'Saturday','Yes','Yes')))))))

Adding Visualizations

Graph 1

  • ggplot, dplyr and lubridate packages are used to get this line graph.
  • The visual below shows; monthly distribution of Total System Margin Prices.

Interpreteations

  • It is obvious that there is strong positive relationship between energy usage and ‘System Marginal Price’. If demand rises, price increases.
  • With the knowledge above we can say that September 3 is the day, that the energy consumption is the highest. Fatih Dönmez, Minister of Energy and Natural Resources, stated that the all-time highs were reached on September 3, in daily electricity production and hourly electricity consumption.For Further Details
plot1data = v2 %>% group_by(Days_of_the_Month = lubridate::day(Date_Time)) %>% summarise(Sum_of_SMP = sum(`System Marginal Price`))
ggplot(plot1data, aes(x=Days_of_the_Month, y=Sum_of_SMP)) +
    geom_line()+ theme_minimal() +
  labs(x = "Days of the Month",y = "Sum of System Margin Prices")

Graph 2

  • ggplot, dplyr and lubridate packages are used to get this Pie chart.
  • The chart below shows, the average electricity usage by the day of the week.

Interpreteations

  • It is a bit difficult to conclude that electricity is used too much or too few in a certain day.
  • Nevertheless, if you look carefully, it can be concluded that electricity is consumed at most on Thursdays and at least on Saturdays.
  • The second day with the lowest electricity consumption is Sundays.
  • With looking results, We can say that the average amount of electricity consumption on weekends is less than the average amount of electricity consumption on weekdays.
v2 %>% group_by(Days_of_the_Week = lubridate::wday(Date_Time, label=TRUE)) %>% summarise(Mean_of_SMP = mean(`System Marginal Price`))
## # A tibble: 7 x 2
##   Days_of_the_Week Mean_of_SMP
##   <ord>                  <dbl>
## 1 Sun                     292.
## 2 Mon                     322.
## 3 Tue                     323.
## 4 Wed                     333.
## 5 Thu                     395.
## 6 Fri                     333.
## 7 Sat                     262.
ggplot(v2 %>% group_by(Days_of_the_Week = lubridate::wday(Date_Time, label=TRUE)) %>% summarise(Mean_of_SMP = mean(`System Marginal Price`)),aes(x="", y=Mean_of_SMP, fill=Days_of_the_Week)) +geom_bar(stat='identity',width = 1)+coord_polar("y")+
  labs(x = "Days of the Week",y = "Average of System Margin Prices")

Graph 3

  • ggplot, dplyr and lubridate packages are used to get this bar chart.
  • The chart below shows, the electricity usage by hours in weekdays and weekends breakdown

Interpreteations

  • When looking at the graph, it can be said that the change in electricity consumption according to hours on the weekend is quite low.
  • On the other hand, electricity consumption varies considerably according to the hours during the week.
  • The lowest electricity consumption is between 5:00 and 7:00 o’clock both on weekdays and weekends, and highest in between 15:00 to 20:00.
v4 = v3 %>% rename( SMP = 'System Marginal Price')
ggplot(v4, aes(x= JTime , y= SMP ,color=isWeekend)) +
    geom_bar(stat='identity')+ theme_minimal() +
  labs(x = "Hours of the Day",y = "Total System Marginal Price")