library(tidyverse) # ggplot, lubridate, dplyr, stringr, readr...
library(praise)
library(gganimate)
Objects Launched into Space
The Data
This week we’re exploring the annual number of objects launched into outer space! Our World in Data processed the data from the Online Index of Objects Launched into Outer Space, maintained by the United Nations Office for Outer Space Affairs since 1962. h/t Data is Plural.
<- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2024/2024-04-23/outer_space_objects.csv') |>
outer_space_objects rename(region = Entity) |>
mutate(region = case_when(
== "United States" ~"USA",
region TRUE ~ region
|>
)) filter(!is.na(Code))
<- map_data("world") temp
<- data_frame(expand.grid(Year = c(1990:2023),
region_grid region = unique(outer_space_objects$region)))
<- left_join(region_grid,
outer_space_objects_full group_by(outer_space_objects, region)) |>
mutate(num_objects = case_when(
is.na(num_objects) ~ 0,
TRUE ~ num_objects
|>
)) group_by(region) |>
arrange(region, Year) |>
mutate(cum_objs = cumsum(num_objects))
<- map_data("world") |>
world_map select(-subregion, -order)
<- data_frame(expand.grid(Year = c(1980:2023),
region_grid region = unique(world_map$region)))
<- region_grid |>
cum_vals left_join(outer_space_objects, by = c("region", "Year")) |>
mutate(num_objects = case_when(
is.na(num_objects) ~ 0,
TRUE ~ num_objects
|>
)) group_by(region) |>
arrange(region, Year) |>
mutate(cum_objs = log(cumsum(num_objects), 10))
<- world_map |> left_join(cum_vals)
world_map
|>
world_map #filter(Year == 2020) |>
select(long, lat, group, region, Year, cum_objs) |>
drop_na() |>
ggplot(aes(map_id = region, fill = cum_objs)) +
geom_map(map = world_map,
aes(x = long, y = lat, group = group)) +
theme_minimal() +
transition_states(Year) +
#transition_reveal(Year) +
labs(x = "", y = "", fill = "") +
ggtitle('Number of launched objects (log10 scale)',
subtitle = 'as of {closest_state}')
praise()
[1] "You are world-class!"