This HTML document is created from the associated R Markdown file. In this assignment, I have organized data in various tibbles, turning them into more userful form using functions of tidyverse package. I have also done operations on relational data to perform analysis on more than one tables at one time.
library(ggplot2) #Package to produce complex multi-layered graphs in R
library(tidyverse) #Set of packages including dpylr and ggplot
The markdown is based on seven data sets that contains information about United States Air Force bomber aircrafts. Following variables are parts of these data sets:
Type: Represents the type of Bomber aircrafts
MD: Combination of basic mission of the aircraft and the design number
FY: Fiscal year from 1996-2014
Cost: Represents the total operational cost for flying, maintaining, repairing, and managing the aircraft
FH: Represents the flying hours, which is the total time the aircraft is in the air flying a mission or in training
Gallons: Represents the total gallons of fuel burned by the aircraft
Note: The data sets contains no missing values or empty rows.
bomber_wide<-read_rds("bomber_wide.rds")
bomber_wide<-as_tibble(bomber_wide)
bomber_wide%>%
gather( key="Year", value="FH", c(-(Type:MD)))
bomber_long<-read_rds("bomber_long.rds")
bomber_long<-as_tibble(bomber_long)
bomber_long%>%
spread(key="Output", value="Value")
bomber_combined<-read_rds("bomber_combined.rds")
bomber_combined<-as_tibble(bomber_combined)
bomber_combined%>%
separate(AC, into = c("Type", "MD"), sep=" ")
bomber_prefix<-read_rds("bomber_prefix.rds")
bomber_prefix<-as_tibble(bomber_prefix)
bomber_prefix%>%
unite(MD, prefix,number,sep="-")%>%
spread(key="Output", value="Value")
bomber_mess<-read_rds("bomber_mess.rds")
bomber_mess<-as_tibble(bomber_mess)
bomber_mess%>%
unite(MD, prefix,number,sep="-")%>%
separate(Metric, into=c("FY", "Output"))%>%
spread(key="Output", value="Value")
bomber_mess %>%
unite(MD,prefix,number,sep="-") %>%
separate(Metric,into = c("FY","Output"),sep="_")%>%
ggplot(aes(x=FY, y=Value,group=MD, colour = MD)) +
geom_line() + geom_point() + facet_grid(Output~., scales = "free") +
ggtitle("Mission Design Aircrafts Metrics") +
labs(y="Value", x="Year")+
theme(axis.text=element_text(size=6),
axis.title=element_text(size=6))
ws_programmatics <- as_tibble(read_rds("ws_programmatics.rds"))
ws_categorization <- as_tibble(read_rds("ws_categorizations.rds"))
ws_programmatics %>%
left_join(ws_categorization,by=c("Base","MD")) %>%
filter(FY == 2014 & Base == "MINOT AFB (ND)") %>%
filter(System=="AIRCRAFT" | System=="MISSILES") %>%
group_by(System) %>%
summarise(Total_Sum = sum(Total_O.S,na.rm=TRUE),Total_end_Strength = sum(End_Strength,na.rm=TRUE))
ws_programmatics %>%
left_join(ws_categorization,by=c("Base","MD")) %>%
filter(FY == 2014) %>%
group_by(Base) %>%
summarise(CPFH = sum(Total_O.S,na.rm=TRUE)/sum(FH,na.rm=TRUE))%>%
filter(CPFH != Inf) %>%
arrange(desc(CPFH)) %>%
head(n=10) %>%
select(Base,CPFH)%>%
ggplot() +
geom_bar(mapping = aes(x = reorder(Base,CPFH),y=CPFH),stat="Identity") +
coord_flip() +
ggtitle(" Top 10 bases with the highest cost per flying hours") +
labs(y="Cost/Flying Hours", x="Bases")
ws_programmatics %>%
left_join(ws_categorization,by=c("Base","MD")) %>%
gather("Output","Value",c(FY,System,FH)) %>%
group_by(Output) %>%
ggplot(mapping=aes(x=End_Strength,y=Total_O.S, color=Output)) +
geom_point() + facet_grid(~Output)