Nations Analysis Sadiya Sow

Quarto

Quarto enables you to weave together content and executable code into a finished document. To learn more about Quarto see https://quarto.org.

Running Code

When you click the Render button a document will be generated that includes both content and the output of embedded code. You can embed code like this:



library(tidyverse)

# Load the data
nations <- read_csv("nations.csv")

nations <- nations %>%
  mutate(gdp = (gdp_percap * population) / 1e12)


nations_filtered <- nations %>%
  filter(country %in% c("United States", "China", "Japan", "Germany"))

ggplot(nations_filtered, aes(x = year, y = gdp, color = country)) +
  geom_point() +
  geom_line() +
  scale_color_brewer(palette = "Set1") +
  labs(title = "GDP Trends for Select Countries",
       y = "GDP (Trillions $)",
       x = "Year") +
  theme_minimal()

nations_region <- nations %>%
  group_by(region, year) %>%
  summarise(GDP = sum(gdp, na.rm = TRUE), .groups = "drop")

ggplot(nations_region, aes(x = year, y = GDP, fill = region)) +
  geom_area(color = "white", linewidth = 0.2) +
  scale_fill_brewer(palette = "Set2") +
  labs(title = "Total GDP by Region",
       y = "GDP (Trillions $)",
       x = "Year") +
  theme_minimal()

You can add options to executable code like this

[1] 4

The echo: false option disables the printing of code (only output is displayed).