Acquisition and Introduction of the Data

# Temporary file for "Planning"
planning_temp=tempfile(fileext=".xlsx")
# Temporary file for "Production"
production_temp=tempfile(fileext=".xlsx")
# Temporary file for "Consumption"
consumption_temp=tempfile(fileext=".xlsx")

# Downloading file from repository to the "Planning" temp
download.file("https://raw.githubusercontent.com/pjournal/mef03g-Kar-R-sizlar/master/4-year-planning.csv?raw=true",destfile=planning_temp,mode='wb')
# Downloading file from repository to the "Production" temp
download.file("https://raw.githubusercontent.com/pjournal/mef03g-Kar-R-sizlar/master/4-year-production.csv?raw=true",destfile=production_temp,mode='wb')
# Downloading file from repository to the "Consumption" temp
download.file("https://raw.githubusercontent.com/pjournal/mef03g-Kar-R-sizlar/master/4-year-consumption.csv?raw=true",destfile=consumption_temp,mode='wb')

# Reading the csv files.
planning_raw_data=read.csv(planning_temp,skip=1)
production_raw_data=read.csv(production_temp,skip=1)
consumption_raw_data=read.csv(consumption_temp,skip=1)

# Removing the temp files
file.remove(planning_temp)
## [1] TRUE
file.remove(production_temp)
## [1] TRUE
file.remove(consumption_temp)
## [1] TRUE

Preparation and Introduction of Planning Data

  • 4 Year Planning Data: This data includes 33599 rows and 15 variables for the planned pruduction between January 1st, 2016 and October 31st, 2019
# Proper Column Names
colnames(planning_raw_data) <-  c('tarih', 'saat', 'toplam_mwh', 'dogal_gaz', 'ruzgar', 'linyit', 'tas_komur', 'ithal_komur', 'fuel_oil', 'jeotermal', 'barajli', 'nafta', 'biyokutle', 'akarsu', 'diger')
# Proper Data Format
planning_raw_data[,3:15]  <- as.data.frame(lapply(planning_raw_data[,3:15], function(x) as.numeric(gsub(",", ".", gsub("\\.", "", x)))))
planning_raw_data$tarih <-as.character(planning_raw_data$tarih)
planning_raw_data$saat <-as.character(planning_raw_data$saat)
head(planning_raw_data, 10)
##         tarih  saat toplam_mwh dogal_gaz ruzgar  linyit tas_komur
## 1  01.01.2016 01:00   18735.09   5471.14 168.48 4139.53       736
## 2  01.01.2016 02:00   17662.05   5182.14 168.44 4139.53       736
## 3  01.01.2016 03:00   17059.91   5146.13 159.71 4139.53       736
## 4  01.01.2016 04:00   16903.33   4990.13 149.83 4139.53       736
## 5  01.01.2016 05:00   16845.48   4941.13 138.38 4139.53       736
## 6  01.01.2016 06:00   17001.33   5116.08 120.18 4139.53       736
## 7  01.01.2016 07:00   16740.74   4993.23 109.84 4139.53       594
## 8  01.01.2016 08:00   17864.68   5643.54 101.52 4139.53       594
## 9  01.01.2016 09:00   19420.21   6237.16  95.73 4139.53       594
## 10 01.01.2016 10:00   20912.93   7964.49  90.42 4139.53       594
##    ithal_komur fuel_oil jeotermal barajli nafta biyokutle akarsu diger
## 1         4587      115     104.1  3166.0     5         0 122.84   120
## 2         4470      115     104.1  2499.0     5         0 122.84   120
## 3         4470      115     104.1  1943.0     5         0 121.44   120
## 4         4470      115     104.1  1943.0     5         0 130.74   120
## 5         4470      115     104.1  1943.0     5         0 133.34   120
## 6         4470      115     104.1  1943.0     5         0 132.44   120
## 7         4470      115     104.1  1951.5     5         0 138.54   120
## 8         4470      115     104.1  2428.5     5         0 143.49   120
## 9         4612      115     104.0  3183.5     5         0 214.29   120
## 10        4612      115     101.5  2966.5     5         0 204.49   120

Preparation and Introduction of Production Data

  • 4 Year Production Data: This data includes 33597 rows and 18 variables for the actual pruduction between January 1st, 2016 and October 31st, 2019
# Defining Column Names
colnames(production_raw_data) <-  c('tarih', 'saat', 'toplam_mwh', 'dogal_gaz', 'barajli', 'linyit', 'akarsu', 'ithal_komur', 'ruzgar', 'gunes', 'fuel_oil', 'jeotermal', 'asfaltit_komur', 'tas_komur', 'biyokutle', 'nafta', 'lng', 'uluslararasi')
# Proper Data Format
production_raw_data[,3:18]  <- as.data.frame(lapply(production_raw_data[,3:18], function(x) as.numeric(gsub(",", ".", gsub("\\.", "", x)))))
production_raw_data$tarih <-as.character(production_raw_data$tarih)
production_raw_data$saat <-as.character(production_raw_data$saat)
head(production_raw_data, 10)
##         tarih  saat toplam_mwh dogal_gaz barajli  linyit  akarsu
## 1  01.01.2016 01:00   24491.99   6430.37 3604.49 4997.36  546.70
## 2  01.01.2016 02:00   23109.42   5814.91 2865.77 5018.45  559.95
## 3  01.01.2016 03:00   22037.52   5668.09 2156.75 4984.45  551.79
## 4  01.01.2016 04:00   21527.40   5811.11 1665.71 4942.55  521.65
## 5  01.01.2016 05:00   21560.19   5899.45 1809.77 4949.23  591.53
## 6  01.01.2016 06:00   21792.83   6009.46 2152.58 4883.43  575.70
## 7  01.01.2016 07:00   21354.45   6034.40 1726.42 4866.64  585.93
## 8  01.01.2016 08:00   22468.05   6464.52 2664.15 4691.56  702.13
## 9  01.01.2016 09:00   24627.01   6897.42 3905.58 4759.37 1081.65
## 10 01.01.2016 10:00   26689.69   8592.73 4273.13 4830.44 1191.11
##    ithal_komur  ruzgar gunes fuel_oil jeotermal asfaltit_komur tas_komur
## 1      5269.60 2277.69     0    174.3    485.05          92.73     451.5
## 2      5165.70 2278.95     0    176.1    485.97         128.06     455.5
## 3      5148.64 2123.17     0    175.1    479.14         134.68     455.5
## 4      5123.66 2057.80     0    177.2    466.16         136.89     462.5
## 5      4917.75 1987.09     0    178.0    478.42         134.68     451.5
## 6      4981.60 1883.21     0    192.1    479.96           4.41     466.5
## 7      5129.63 1722.24     0    190.6    473.14           0.00     464.5
## 8      5156.67 1514.98     0    191.4    463.26           0.00     464.5
## 9      5284.62 1427.86     0    189.1    455.94           8.83     459.5
## 10     5290.62 1196.47     0    193.1    449.04          50.78     462.5
##    biyokutle nafta lng uluslararasi
## 1     162.20     0   0            0
## 2     160.06     0   0            0
## 3     160.21     0   0            0
## 4     162.17     0   0            0
## 5     162.77     0   0            0
## 6     163.88     0   0            0
## 7     160.95     0   0            0
## 8     154.88     0   0            0
## 9     157.14     0   0            0
## 10    159.77     0   0            0

Preparation and Introduction of Consumption Data

  • 4 Year Consumpiton Data: This data includes 33575 rows and 3 variables for actual consumption between January 1st, 2016 and October 31st, 2019
# Defining Column Names
colnames(consumption_raw_data) <-  c('tarih', 'saat', 'tuketim_miktari_mwh')
# Proper Data Format
consumption_raw_data <-  cbind(consumption_raw_data, consumption_raw_data)
consumption_raw_data[,3:6]  <- as.data.frame(lapply(consumption_raw_data[,3:6], function(x) as.numeric(gsub(",", ".", gsub("\\.", "", x)))))
## Warning in FUN(X[[i]], ...): NAs introduced by coercion
consumption_raw_data <- consumption_raw_data[, 1:3]
consumption_raw_data$tarih <-as.character(consumption_raw_data$tarih)
consumption_raw_data$saat <-as.character(consumption_raw_data$saat)
head(consumption_raw_data, 10)
##         tarih  saat tuketim_miktari_mwh
## 1  01.01.2016 01:00            24991.82
## 2  01.01.2016 02:00            23532.61
## 3  01.01.2016 03:00            22464.78
## 4  01.01.2016 04:00            22002.91
## 5  01.01.2016 05:00            21957.08
## 6  01.01.2016 06:00            22203.54
## 7  01.01.2016 07:00            21844.16
## 8  01.01.2016 08:00            23094.73
## 9  01.01.2016 09:00            25202.27
## 10 01.01.2016 10:00            27224.96
# Creating RDS files
saveRDS(planning_raw_data, file = "/Users/m2lmacbook1/Desktop/Phase 2 - Data Explanations/planning.rds")
saveRDS(production_raw_data, file = "/Users/m2lmacbook1/Desktop/Phase 2 - Data Explanations/production.rds")
saveRDS(consumption_raw_data, file = "/Users/m2lmacbook1/Desktop/Phase 2 - Data Explanations/consumption.rds")

# Links to download RDS files from Group PJ
# * [Planning](https://github.com/pjournal/mef03g-Kar-R-sizlar/blob/master/planning.rds)
# * [Production](https://github.com/pjournal/mef03g-Kar-R-sizlar/blob/master/production.rds)
# * [Consumpiton](https://github.com/pjournal/mef03g-Kar-R-sizlar/blob/master/consumption.rds)

# Reading the RDS files from Group PJ 
# Temporary file for "Planning"
planning_temp_2=tempfile(fileext=".rds")
# Temporary file for "Production"
production_temp_2=tempfile(fileext=".rds")
# Temporary file for "Consumption"
consumption_temp_2=tempfile(fileext=".rds")

# Downloading file from repository to the "Planning" temp
download.file("https://github.com/pjournal/mef03g-Kar-R-sizlar/blob/master/planning.rds?raw=true",destfile=planning_temp_2,mode='wb')
# Downloading file from repository to the "Production" temp
download.file("https://github.com/pjournal/mef03g-Kar-R-sizlar/blob/master/production.rds?raw=true",destfile=production_temp_2,mode='wb')
# Downloading file from repository to the "Consumption" temp
download.file("https://github.com/pjournal/mef03g-Kar-R-sizlar/blob/master/consumption.rds?raw=true",destfile=consumption_temp_2,mode='wb')

# Reading the RDS files
planning_raw_data=read.csv(planning_temp_2)
production_raw_data=read.csv(production_temp_2)
consumption_raw_data=read.csv(consumption_temp_2)

# Removing the temp files
file.remove(planning_temp_2)
## [1] TRUE
file.remove(production_temp_2)
## [1] TRUE
file.remove(consumption_temp_2)
## [1] TRUE

For more information on the topics below, please visit the Project Proposal page;

  • Brief
  • Objectives
  • Plan
  • References