Skip to content

Instantly share code, notes, and snippets.

@felixhaass
Created April 22, 2015 17:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save felixhaass/5dd3be738060b12b24a2 to your computer and use it in GitHub Desktop.
Save felixhaass/5dd3be738060b12b24a2 to your computer and use it in GitHub Desktop.
Plot annual number of spacewalks by Russia & US
library(readr)
# read
eva <- read_csv("Extra-vehicular_Activity__EVA__-_US_and_Russia.csv")
# extract years from somewhat inconsisten Date variable
eva$year <- stringi::stri_extract_last_regex(eva$Date, "\\d{4}") # get year
eva$year <- as.numeric(eva$year)
# prepare plot data
plot_eva <- eva %>%
group_by(year, Country) %>%
summarise(eva_count = n())
# plot all the things!
spacewalk <- ggplot(plot_eva, aes(x=year, y = eva_count, group = Country, color = Country)) +
geom_line() +
theme_bw() +
theme(legend.position = "none") +
scale_color_brewer(palette = "Dark2") +
facet_wrap(~Country) +
labs(y = "Count of Extra-Vehicular Activites (Spacewalks) \n", x = "")
# save
ggsave(plot = spacewalk, file = "spacewalk.png", type = "cairo-png",
units = "in", dpi = 200, height = 4.5, width = 8)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment