-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlaunchSuccess.Rmd
40 lines (31 loc) · 1.07 KB
/
launchSuccess.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
---
title: "Tidy Tuesday Jan 15 2019"
output: html_document
---
```{r setup, include=TRUE}
knitr::opts_chunk$set(echo = TRUE)
library(tidyverse)
space.dat2 <- read.csv("https://raw.githubusercontent.com/TheEconomist/graphic-detail-data/master/data/2018-10-20_space-launches/launches.csv")
```
# What is the Success Rate for State Compared to Private Launches?
```{r figure}
sucDat <- space.dat2 %>%
mutate(success01 = ifelse(category == "F", 0, 1)) %>%
group_by(launch_year, agency_type) %>%
summarize(propSuc = mean(success01))
plot <- ggplot(data=sucDat, aes(y=propSuc, x=launch_year))+
geom_line(aes(color=agency_type))+
geom_point(aes(color=agency_type))+
theme_bw()+
geom_line(stat="smooth", method="loess", aes(color=agency_type), alpha=0.75)+
ylim(c(0,1))+
labs(title="Proportion of Launch Success \n Over Time by Agency Type",
x="Launch Year", y="Proportion of Successful Launches")+
scale_color_discrete(guide=FALSE)+
facet_grid(agency_type~.)+
theme(plot.title=element_text(hjust=0.5))
print(plot)
pdf("launchSuc_plot.pdf")
print(plot)
dev.off()
```