Load the libraries
library(httr)
library(jsonlite)
library(ggplot2)
Count launches per year
launch_data$year <- format(launch_data$date, "%Y")
launch_counts <- as.data.frame(table(launch_data$year))
colnames(launch_counts) <- c("year", "count")
Convert ‘year’ to numeric for plotting
launch_counts$year <- as.numeric(as.character(launch_counts$year))
launch_counts$count <- as.numeric(launch_counts$count) # just in case
Plot launches per year
ggplot(launch_counts, aes(x = year, y = count, group = 1)) +
geom_line(color = "steelblue", linewidth = 1.2) +
geom_point(color = "darkred", size = 3) +
theme_minimal() +
labs(
title = "SpaceX Launches per Year",
x = "Year",
y = "Number of Launches"
)
