title: โCount_2010_Run_โ output: html_document: code_folding: hide
library(readxl)
library(lubridate)
library(plyr)
library(dplyr)
library(tidyr)
library(ggplot2)
Natural gas combine cycle plant generation depends upon market demand . Attemp has been made to calculate the number of days plant was supplying power to grid.It is a first attempt for a comparitive study with counting wind generating days
G10<-read_excel("GOC-2010.xlsx")
## New names:
## * `` -> ...3
G10$DATE <- as.Date(G10$DATE, format = "%Y-%m-%d") # Changing to Date format
colnames(G10)[colnames(G10)=="DATE"] <- "Date"
##11$Date <- as.Date(G12$Date, format = "%Y-%m-%d") # Changing to Date format
Dz_10Total<-G10 %>% group_by(Date) %>% summarize(Total_2010_Gen=sum(`TOTAL`),n=n())
Dz_10Goreway<-G10 %>% group_by(Date) %>% summarize(Goreway_2010_Total=sum(`SITHE GOREWAY`),n=n())
Dz_10Halton<-G10 %>% group_by(Date) %>% summarize(Halton_2010_Total=sum(HALTONHILLS),n=n())
Dz_10Portland<-G10 %>% group_by(Date) %>% summarize(Portlands_2010_Total=sum(PORTLANDS),n=n())
Dz_10Greenfeild<-G10 %>% group_by(Date) %>% summarize(GEC_2010_Total=sum(`GREENFIELD ENERGY CENTRE`),n=n())
Dz_10Brighton<-G10 %>% group_by(Date) %>% summarize(Brigton_2010_Total=sum(`BRIGHTON BEACH`),n=n())
Dz_10GB<-cbind(Dz_10Total[,-3],Dz_10Goreway[,2],Dz_10Halton[,2],Dz_10Portland[,2],Dz_10Greenfeild[,2],Dz_10Brighton[,2])
Dz_10Goreway
## # A tibble: 366 x 3
## Date Goreway_2010_Total n
## <date> <dbl> <int>
## 1 2010-01-01 0 24
## 2 2010-01-02 0 24
## 3 2010-01-03 11 24
## 4 2010-01-04 6423 24
## 5 2010-01-05 3168 24
## 6 2010-01-06 5513 24
## 7 2010-01-07 6166 24
## 8 2010-01-08 5968 24
## 9 2010-01-09 432 24
## 10 2010-01-10 0 24
## # ... with 356 more rows
any(is.na(Dz_10GB))
## [1] TRUE
sum(is.na(Dz_10GB))
## [1] 7
colSums(is.na(Dz_10GB))
## Date Total_2010_Gen Goreway_2010_Total
## 1 1 1
## Halton_2010_Total Portlands_2010_Total GEC_2010_Total
## 1 1 1
## Brigton_2010_Total
## 1
nrow(Dz_10GB)
## [1] 366
Dz_10GB<-na.omit(Dz_10GB)
any(is.na(Dz_10GB))
## [1] FALSE
nrow(Dz_10GB)
## [1] 365
head(Dz_10GB)
## Date Total_2010_Gen Goreway_2010_Total Halton_2010_Total
## 1 2010-01-01 400470 0 0
## 2 2010-01-02 430273 0 0
## 3 2010-01-03 455882 11 0
## 4 2010-01-04 481308 6423 0
## 5 2010-01-05 482227 3168 0
## 6 2010-01-06 483561 5513 0
## Portlands_2010_Total GEC_2010_Total Brigton_2010_Total
## 1 0 0 0
## 2 1489 0 0
## 3 0 1 2713
## 4 3574 4075 2688
## 5 3210 2196 0
## 6 3319 0 2365
any(is.na(Dz_10Goreway))
## [1] TRUE
sum(is.na(Dz_10Goreway))
## [1] 2
colSums(is.na(Dz_10Goreway))
## Date Goreway_2010_Total n
## 1 1 0
nrow(Dz_10Goreway)
## [1] 366
Dz_10Goreway<-na.omit(Dz_10Goreway)
any(is.na(Dz_10Goreway))
## [1] FALSE
nrow(Dz_10Goreway)
## [1] 365
head(Dz_10Goreway)
## # A tibble: 6 x 3
## Date Goreway_2010_Total n
## <date> <dbl> <int>
## 1 2010-01-01 0 24
## 2 2010-01-02 0 24
## 3 2010-01-03 11 24
## 4 2010-01-04 6423 24
## 5 2010-01-05 3168 24
## 6 2010-01-06 5513 24
Goreway_U_Status_10<-cut(Dz_10Goreway$Goreway_2010_Total,breaks = c(0,100,50000),labels = c(0,1))
Goreway_U_Status_10<-cbind(Dz_10Goreway,Goreway_U_Status_10)
#Goreway_U_Status_10
any(is.na(Goreway_U_Status_10))
## [1] TRUE
Goreway_U_Status_10[is.na(Goreway_U_Status_10)]=0
head(Goreway_U_Status_10)
## Date Goreway_2010_Total n Goreway_U_Status_10
## 1 2010-01-01 0 24 0
## 2 2010-01-02 0 24 0
## 3 2010-01-03 11 24 0
## 4 2010-01-04 6423 24 1
## 5 2010-01-05 3168 24 1
## 6 2010-01-06 5513 24 1
##aa_G_10<-count(Goreway_U_Status_10,"Goreway_U_Status_10")
aa_G_10<-Goreway_U_Status_10 %>% count(Goreway_U_Status_10)
names(aa_G_10)[1]="Running_Status"
names(aa_G_10)[2]="Goreway_Run"
aa_G_10
## # A tibble: 2 x 2
## Running_Status Goreway_Run
## <fct> <int>
## 1 0 65
## 2 1 300
any(is.na(Dz_10Halton))
## [1] TRUE
sum(is.na(Dz_10Halton))
## [1] 2
colSums(is.na(Dz_10Halton))
## Date Halton_2010_Total n
## 1 1 0
nrow(Dz_10Halton)
## [1] 366
Dz_10Halton<-na.omit(Dz_10Halton)
any(is.na(Dz_10Halton))
## [1] FALSE
nrow(Dz_10Halton)
## [1] 365
head(Dz_10Halton)
## # A tibble: 6 x 3
## Date Halton_2010_Total n
## <date> <dbl> <int>
## 1 2010-01-01 0 24
## 2 2010-01-02 0 24
## 3 2010-01-03 0 24
## 4 2010-01-04 0 24
## 5 2010-01-05 0 24
## 6 2010-01-06 0 24
Halton_U_Status_10<-cut(Dz_10Halton$Halton_2010_Total,breaks = c(0,100,50000),labels = c(0,1))
Halton_U_Status_10<-cbind(Dz_10Halton,Halton_U_Status_10)
Halton_U_Status_10[is.na(Halton_U_Status_10)]=0
#Halton_U_Status_10
#aa_H_10<-count(Halton_U_Status_10,"Halton_U_Status_10")
aa_H_10<-Halton_U_Status_10 %>% count(Halton_U_Status_10)
names(aa_H_10)[1]="Running_Status"
names(aa_H_10)[2]="Halton_Run"
aa_H_10
## # A tibble: 2 x 2
## Running_Status Halton_Run
## <fct> <int>
## 1 0 213
## 2 1 152
any(is.na(Dz_10Portland))
## [1] TRUE
sum(is.na(Dz_10Portland))
## [1] 2
colSums(is.na(Dz_10Portland))
## Date Portlands_2010_Total n
## 1 1 0
nrow(Dz_10Portland)
## [1] 366
Dz_10Portland<-na.omit(Dz_10Portland)
any(is.na(Dz_10Portland))
## [1] FALSE
nrow(Dz_10Portland)
## [1] 365
head(Dz_10Portland)
## # A tibble: 6 x 3
## Date Portlands_2010_Total n
## <date> <dbl> <int>
## 1 2010-01-01 0 24
## 2 2010-01-02 1489 24
## 3 2010-01-03 0 24
## 4 2010-01-04 3574 24
## 5 2010-01-05 3210 24
## 6 2010-01-06 3319 24
Portlands_U_Status_10<-cut(Dz_10Portland$Portlands_2010_Total,breaks = c(0,100,50000),labels = c(0,1))
Portlands_U_Status_10<-cbind(Dz_10Portland,Portlands_U_Status_10)
Portlands_U_Status_10[is.na(Portlands_U_Status_10)]=0
#Portlands_U_Status_10
#aa_P_10<-count(Portlands_U_Status_10,"Portlands_U_Status_10")
aa_P_10<-Portlands_U_Status_10 %>% count(Portlands_U_Status_10)
names(aa_P_10)[1]="Running_Status"
names(aa_P_10)[2]="Portland_Run"
aa_P_10
## # A tibble: 2 x 2
## Running_Status Portland_Run
## <fct> <int>
## 1 0 120
## 2 1 245
any(is.na(Dz_10Greenfeild))
## [1] TRUE
sum(is.na(Dz_10Greenfeild))
## [1] 2
colSums(is.na(Dz_10Greenfeild))
## Date GEC_2010_Total n
## 1 1 0
nrow(Dz_10Greenfeild)
## [1] 366
Dz_10Greenfeild<-na.omit(Dz_10Greenfeild)
any(is.na(Dz_10Greenfeild))
## [1] FALSE
nrow(Dz_10Greenfeild)
## [1] 365
head(Dz_10Greenfeild)
## # A tibble: 6 x 3
## Date GEC_2010_Total n
## <date> <dbl> <int>
## 1 2010-01-01 0 24
## 2 2010-01-02 0 24
## 3 2010-01-03 1 24
## 4 2010-01-04 4075 24
## 5 2010-01-05 2196 24
## 6 2010-01-06 0 24
Greenfeild_U_Status_10<-cut(Dz_10Greenfeild$GEC_2010_Total,breaks = c(0,100,50000),labels = c(0,1))
Greenfeild_U_Status_10<-cbind(Dz_10Greenfeild,Greenfeild_U_Status_10)
Greenfeild_U_Status_10[is.na(Greenfeild_U_Status_10)]= 0
#Greenfeild_U_Status_10
#aa_GEC_10<-count(Greenfeild_U_Status_10,"Greenfeild_U_Status_10")
aa_GEC_10<-Greenfeild_U_Status_10 %>% count(Greenfeild_U_Status_10)
names(aa_GEC_10)[1]="Running_Status"
names(aa_GEC_10)[2]="Greenfeild_Run"
aa_GEC_10
## # A tibble: 2 x 2
## Running_Status Greenfeild_Run
## <fct> <int>
## 1 0 91
## 2 1 274
any(is.na(Dz_10Brighton))
## [1] TRUE
sum(is.na(Dz_10Brighton))
## [1] 2
colSums(is.na(Dz_10Brighton))
## Date Brigton_2010_Total n
## 1 1 0
nrow(Dz_10Brighton)
## [1] 366
Dz_10Brighton<-na.omit(Dz_10Brighton)
any(is.na(Dz_10Brighton))
## [1] FALSE
nrow(Dz_10Brighton)
## [1] 365
head(Dz_10Brighton)
## # A tibble: 6 x 3
## Date Brigton_2010_Total n
## <date> <dbl> <int>
## 1 2010-01-01 0 24
## 2 2010-01-02 0 24
## 3 2010-01-03 2713 24
## 4 2010-01-04 2688 24
## 5 2010-01-05 0 24
## 6 2010-01-06 2365 24
Brighton_U_Status_10<-cut(Dz_10Brighton$Brigton_2010_Total,breaks = c(0,100,50000),labels = c(0,1))
Brighton_U_Status_10<-cbind(Dz_10Brighton,Brighton_U_Status_10)
Brighton_U_Status_10[is.na(Brighton_U_Status_10)]=0
#Brighton_U_Status_10
#aa_BB_10<-count(Brighton_U_Status_10,"Brighton_U_Status_10")
aa_BB_10<-Brighton_U_Status_10 %>% count(Brighton_U_Status_10)
names(aa_BB_10)[1]="Running_Status"
names(aa_BB_10)[2]="Brighton_Run"
aa_BB_10
## # A tibble: 2 x 2
## Running_Status Brighton_Run
## <fct> <int>
## 1 0 202
## 2 1 163
U_R_Status_10<-cbind(aa_G_10,aa_H_10[,2],aa_P_10[,2],aa_GEC_10[,2],aa_BB_10[,2])
names(U_R_Status_10)[2]="Goreway"
names(U_R_Status_10)[3]="Halton"
names(U_R_Status_10)[4]="Portlands"
names(U_R_Status_10)[5]="Greenfield"
names(U_R_Status_10)[6]="Brigton"
Barplot
count<-as.matrix(U_R_Status_10[,-1])
barplot(count)
##ggplot
Plant_Name <- rep(c("Goreway", "Halton", "Portlands", "Greenfield", "Brighton"), 2)
No_Run <-c(U_R_Status_10[1,2],U_R_Status_10[1,3],U_R_Status_10[1,4],U_R_Status_10[1,5],U_R_Status_10[1,6])
Run<-c(U_R_Status_10[2,2],U_R_Status_10[2,3],U_R_Status_10[2,4],U_R_Status_10[2,5],U_R_Status_10[2,6])
Days <-c(No_Run, Run)
Run_type <-c(rep("No_Run", 5), rep("Run",5))
mydata <-data.frame(Plant_Name, Days)
mydata
## Plant_Name Days
## 1 Goreway 65
## 2 Halton 213
## 3 Portlands 120
## 4 Greenfield 91
## 5 Brighton 202
## 6 Goreway 300
## 7 Halton 152
## 8 Portlands 245
## 9 Greenfield 274
## 10 Brighton 163
p <-ggplot(mydata, aes(Plant_Name, Days))
p +geom_bar(stat= "identity",aes(fill=Run_type),position="dodge")+xlab("Plants Name")+ylab("Number of Days")+theme_bw()
ggplot(data=mydata, aes(x=Plant_Name, y=Days, fill=Run_type)) +
geom_bar(stat="identity", position=position_dodge())+
geom_text(aes(label=Days), vjust=1.6, color="white",
position = position_dodge(0.9), size=3.5)+
scale_fill_brewer(palette="Paired")+
theme_minimal()