getwd()
## [1] "C:/Users/yigit.hakan/Documents/Power Generation"
hakan <- read.csv("electricity_generation.csv", TRUE, ",")
class (hakan)
## [1] "data.frame"
head (hakan)
## ï..LOCATION INDICATOR SUBJECT MEASURE FREQUENCY TIME Value Flag.Codes
## 1 AUS ELECTRICITY NUCLEAR GWH A 1960 0
## 2 AUS ELECTRICITY NUCLEAR GWH A 1961 0
## 3 AUS ELECTRICITY NUCLEAR GWH A 1962 0
## 4 AUS ELECTRICITY NUCLEAR GWH A 1963 0
## 5 AUS ELECTRICITY NUCLEAR GWH A 1964 0
## 6 AUS ELECTRICITY NUCLEAR GWH A 1965 0
str (hakan)
## 'data.frame': 4075 obs. of 8 variables:
## $ ï..LOCATION: Factor w/ 44 levels "AUS","AUT","BEL",..: 1 1 1 1 1 1 1 1 1 1 ...
## $ INDICATOR : Factor w/ 1 level "ELECTRICITY": 1 1 1 1 1 1 1 1 1 1 ...
## $ SUBJECT : Factor w/ 2 levels "NUCLEAR","TOT": 1 1 1 1 1 1 1 1 1 1 ...
## $ MEASURE : Factor w/ 2 levels "GWH","PC_ENRGGEN": 1 1 1 1 1 1 1 1 1 1 ...
## $ FREQUENCY : Factor w/ 1 level "A": 1 1 1 1 1 1 1 1 1 1 ...
## $ TIME : int 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 ...
## $ Value : num 0 0 0 0 0 0 0 0 0 0 ...
## $ Flag.Codes : Factor w/ 4 levels "","L","M","Z": 1 1 1 1 1 1 1 1 1 1 ...
summary (hakan)
## ï..LOCATION INDICATOR SUBJECT MEASURE
## AUS : 113 ELECTRICITY:4075 NUCLEAR:2059 GWH :4032
## AUT : 113 TOT :2016 PC_ENRGGEN: 43
## BEL : 113
## CAN : 113
## CHE : 113
## CHL : 113
## (Other):3397
## FREQUENCY TIME Value Flag.Codes
## A:4075 Min. :1960 Min. : 0 :3746
## 1st Qu.:1974 1st Qu.: 0 L: 192
## Median :1988 Median : 10177 M: 120
## Mean :1988 Mean : 203569 Z: 17
## 3rd Qu.:2002 3rd Qu.: 70295
## Max. :2015 Max. :10457306
## NA's :312
library(tidyverse)
## Loading tidyverse: ggplot2
## Loading tidyverse: tibble
## Loading tidyverse: tidyr
## Loading tidyverse: readr
## Loading tidyverse: purrr
## Loading tidyverse: dplyr
## Conflicts with tidy packages ----------------------------------------------
## filter(): dplyr, stats
## lag(): dplyr, stats
glimpse (hakan)
## Observations: 4,075
## Variables: 8
## $ ï..LOCATION <fctr> AUS, AUS, AUS, AUS, AUS, AUS, AUS, AUS, AUS, AUS,...
## $ INDICATOR <fctr> ELECTRICITY, ELECTRICITY, ELECTRICITY, ELECTRICIT...
## $ SUBJECT <fctr> NUCLEAR, NUCLEAR, NUCLEAR, NUCLEAR, NUCLEAR, NUCL...
## $ MEASURE <fctr> GWH, GWH, GWH, GWH, GWH, GWH, GWH, GWH, GWH, GWH,...
## $ FREQUENCY <fctr> A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A...
## $ TIME <int> 1960, 1961, 1962, 1963, 1964, 1965, 1966, 1967, 19...
## $ Value <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,...
## $ Flag.Codes <fctr> , , , , , , , , , , , , , , , , , , , , , , , ,
hakan %>% filter(ï..LOCATION=="TUR", Flag.Codes=="L")
## ï..LOCATION INDICATOR SUBJECT MEASURE FREQUENCY TIME Value Flag.Codes
## 1 TUR ELECTRICITY NUCLEAR GWH A 2015 NA L
## 2 TUR ELECTRICITY TOT GWH A 2015 NA L
hakan %>% filter(ï..LOCATION=="TUR", Value>200000)
## ï..LOCATION INDICATOR SUBJECT MEASURE FREQUENCY TIME Value Flag.Codes
## 1 TUR ELECTRICITY TOT GWH A 2010 203046
## 2 TUR ELECTRICITY TOT GWH A 2011 217558
## 3 TUR ELECTRICITY TOT GWH A 2012 227707
## 4 TUR ELECTRICITY TOT GWH A 2013 228977
## 5 TUR ELECTRICITY TOT GWH A 2014 239449
hakan %>% filter(ï..LOCATION=="TUR", TIME>2000) %>% select (ï..LOCATION, TIME, Value)
## ï..LOCATION TIME Value
## 1 TUR 2001 0
## 2 TUR 2002 0
## 3 TUR 2003 0
## 4 TUR 2004 0
## 5 TUR 2005 0
## 6 TUR 2006 0
## 7 TUR 2007 0
## 8 TUR 2008 0
## 9 TUR 2009 0
## 10 TUR 2010 0
## 11 TUR 2011 0
## 12 TUR 2012 0
## 13 TUR 2013 0
## 14 TUR 2014 0
## 15 TUR 2015 NA
## 16 TUR 2001 116251
## 17 TUR 2002 123727
## 18 TUR 2003 135248
## 19 TUR 2004 145066
## 20 TUR 2005 155469
## 21 TUR 2006 169543
## 22 TUR 2007 183340
## 23 TUR 2008 189763
## 24 TUR 2009 186619
## 25 TUR 2010 203046
## 26 TUR 2011 217558
## 27 TUR 2012 227707
## 28 TUR 2013 228977
## 29 TUR 2014 239449
## 30 TUR 2015 NA
## 31 TUR 2014 0