Data 110 - Assignment 6 Part 2

nations <- read.csv("C:/Users/panca/Downloads/nations.csv")
library(ggplot2)
library(dplyr)

Attaching package: 'dplyr'
The following objects are masked from 'package:stats':

    filter, lag
The following objects are masked from 'package:base':

    intersect, setdiff, setequal, union
nations_data <- nations |> mutate(gdp = (gdp_percap * population)/1000000000000)
selected_countries <- nations_data |> filter(country %in% c("China","Germany","Japan","United States"))

ggplot(selected_countries, aes(x=year,y=gdp,color=country))+
  geom_line()+
  geom_point()+
  scale_color_brewer(palette = "Set1") +
  labs(
    title="China's Rise to Become the Largest Economy",
    x="Year",
    y="GDP ($Trillion)",
  ) 

region_data <- nations_data |> group_by(region,year) |> summarize(gdp=sum(gdp, na.rm=TRUE))
`summarise()` has regrouped the output.
ℹ Summaries were computed grouped by region and year.
ℹ Output is grouped by region.
ℹ Use `summarise(.groups = "drop_last")` to silence this message.
ℹ Use `summarise(.by = c(region, year))` for per-operation grouping
  (`?dplyr::dplyr_by`) instead.
ggplot(region_data,aes(x=year,y=gdp,fill=region))+
  geom_area(color="white",size=0.1)+
   scale_fill_brewer(palette = "Set2")+
  labs(
    title="GDP by World Bank Region",
    x="Year",
    y="GDP ($Trillion)",
  )
Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
ℹ Please use `linewidth` instead.