library(tidyverse)
library(readxl)
library(ggthemes)
library(lubridate)
#devtools::install_github("Mikata-Project/ggthemr")
#library(ggthemr)
df  <- read_excel("NG_PROD_SUM_A_EPG0_VGV_MMCF_A.xls",sheet=2,col_names=T,skip=2)
colnames(df) <-c("Date","National","Alaska","Alaska_onshore","Alaska_State","Arkansas","California","Calif_onshore","California_State","Federal_Offshore_Calif","Colorado","Offshore_Gulf_of_Mexico","Kansas","Louisiana","Louisiana_onshore","Louisiana_State","Montana","New_Mexico","North_Dakota","Ohio","Oklahoma","Pennsylvania","Texas","Texas_onshore","Texas_State_Offshore","Utah","West_Virginia","Wyoming") 
df$Year  <- year(df$Date)
Alaska <- df %>% mutate(State="Alaska",volume=Alaska/National) %>% select(Year,State,volume)
Arkansas  <- df %>% mutate(State="Arkansas",volume=Arkansas/National) %>% select(Year,State,volume)
California  <- df %>% mutate(State="California",volume=California/National) %>% select(Year,State,volume)
Colorado  <- df %>% mutate(State="Colorado",volume=Colorado/National) %>% select(Year,State,volume)
Kansas  <- df %>% mutate(State="Kansas",volume=Kansas/National) %>% select(Year,State,volume)
Louisiana  <- df %>% mutate(State="Louisiana",volume=Louisiana/National) %>% select(Year,State,volume)
Montana  <- df %>% mutate(State="Montana",volume=Montana/National) %>% select(Year,State,volume)
New_Mexico  <- df %>% mutate(State="New Mexico",volume=New_Mexico/National) %>% select(Year,State,volume)
North_Dakota  <- df %>% mutate(State="North Dakota",volume=North_Dakota/National) %>% select(Year,State,volume)
Ohio  <- df %>% mutate(State="Ohio",volume=Ohio/National) %>% select(Year,State,volume)
Oklahoma  <- df %>% mutate(State="Oklahoma",volume=Oklahoma/National) %>% select(Year,State,volume)
Pennsylvania  <- df %>% mutate(State="Pennsylvania",volume=Pennsylvania/National) %>% select(Year,State,volume)
Texas  <- df %>% mutate(State="Texas",volume=Texas/National) %>% select(Year,State,volume)
Utah  <- df %>% mutate(State="Utah",volume=Utah/National) %>% select(Year,State,volume)
West_Virginia  <- df %>% mutate(State="West Virginia",volume=West_Virginia/National) %>% select(Year,State,volume)
Wyoming  <- df %>% mutate(State="Wyoming",volume=Wyoming/National) %>% select(Year,State,volume)
######
df  <- rbind(Alaska,Arkansas,California,Colorado,Kansas,Louisiana,Montana,New_Mexico,North_Dakota,Ohio,Oklahoma,Pennsylvania,Texas,Utah,West_Virginia,Wyoming)  %>% filter(!is.na(volume))
Other  <- df %>% group_by(Year) %>% summarize(State="Other",volume=1-sum(volume,na.rm=TRUE))
graph_dat  <- full_join(Other,df)
graph_dat$volume  <- 100*graph_dat$volume
stacked  <- ggplot(data=graph_dat,aes(x=Year,y=volume,fill=State)) + geom_area(postion='stacked')  + scale_x_continuous(n.breaks = 10)+ylab(NULL)
ggsave(stacked,file="flared.jpeg")
