setwd("C:/Users/ahmet/Desktop/MEF_BDA/R_Data")
data <- read_xlsx("ptf-smf.xlsx")
data2= data %>% select(Tarih,PTF,SMF)
data2
## # A tibble: 720 x 3
## Tarih PTF SMF
## <dttm> <dbl> <dbl>
## 1 2020-09-01 00:00:00 302. 332.
## 2 2020-09-01 01:00:00 300. 325.
## 3 2020-09-01 02:00:00 293. 318.
## 4 2020-09-01 03:00:00 290 320
## 5 2020-09-01 04:00:00 290 330
## 6 2020-09-01 05:00:00 290 339
## 7 2020-09-01 06:00:00 292. 342.
## 8 2020-09-01 07:00:00 295. 345
## 9 2020-09-01 08:00:00 307. 339.
## 10 2020-09-01 09:00:00 315. 346.
## # ... with 710 more rows
data3=data2 %>% mutate(diff=PTF-SMF, smf_direc=ifelse(PTF>SMF,"Energy Surplus",ifelse(PTF<SMF,"Energy Deficit","Balance"))) %>%
select(Tarih,PTF,SMF,diff, smf_direc)
data3
## # A tibble: 720 x 5
## Tarih PTF SMF diff smf_direc
## <dttm> <dbl> <dbl> <dbl> <chr>
## 1 2020-09-01 00:00:00 302. 332. -30 Energy Deficit
## 2 2020-09-01 01:00:00 300. 325. -25 Energy Deficit
## 3 2020-09-01 02:00:00 293. 318. -25 Energy Deficit
## 4 2020-09-01 03:00:00 290 320 -30 Energy Deficit
## 5 2020-09-01 04:00:00 290 330 -40 Energy Deficit
## 6 2020-09-01 05:00:00 290 339 -49 Energy Deficit
## 7 2020-09-01 06:00:00 292. 342. -50 Energy Deficit
## 8 2020-09-01 07:00:00 295. 345 -49.6 Energy Deficit
## 9 2020-09-01 08:00:00 307. 339. -31.5 Energy Deficit
## 10 2020-09-01 09:00:00 315. 346. -31 Energy Deficit
## # ... with 710 more rows
data_bar=data3 %>% select(smf_direc)
ggplot(data_bar, aes(smf_direc)) +
geom_bar(fill = "forest green") +
labs(x = "", y = "Count")
Percentage of energy deficit is higher than Enerji surplus and balance
data3_day=data3 %>% group_by(day = lubridate::day(Tarih)) %>% summarise(total_ptf=sum(PTF), total_smf=sum(SMF))
## `summarise()` ungrouping output (override with `.groups` argument)
ggplot()+
geom_line(data=data3_day,aes(x=day, y=total_ptf,group=1, colour="darkblue"),size=1 )+
geom_line(data=data3_day,aes(x=day, y=total_smf,group=1, colour="red"),size=1 )+
scale_color_discrete(name = "Categories", labels = c("Daily PTF", "Daily SMF")) + labs(x = "day", y = "Amount")
data_work_hours=data3 %>% mutate(hour = lubridate::hour(Tarih), day = lubridate::day(Tarih)) %>%
select(Tarih,hour,day, PTF, SMF, diff, smf_direc) %>%
mutate(work_hour=ifelse(hour>=9 & hour<19 & day%%7!=6 & day%%7!=5,"yes","no")) %>%
select(Tarih,hour,day, PTF, SMF, diff, smf_direc, work_hour)
data_work = data_work_hours %>% select(everything()) %>%
filter(work_hour=="yes")
data_holiday = data_work_hours %>% select(everything()) %>%
filter(work_hour=="no")
ggplot(data_holiday %>% select(smf_direc), aes(smf_direc)) +
geom_bar(fill="red") +
labs(x = "", y = "Count")
ggplot(data_work %>% select(smf_direc), aes(smf_direc)) +
geom_bar(fill = 'blue') +
labs(x = "", y = "Count")
We can say that in work hours percentage of the energy deficit is too high. Another mean that is higher than normal situation. In result, it is obviously that predicting the real demand is very hard in work hours