The following objects are masked from 'package:stats':
filter, lag
The following objects are masked from 'package:base':
intersect, setdiff, setequal, union
library(ggplot2)library(plotly)
Attaching package: 'plotly'
The following object is masked from 'package:ggplot2':
last_plot
The following object is masked from 'package:stats':
filter
The following object is masked from 'package:graphics':
layout
library(readr)library(viridis)
Loading required package: viridisLite
nations <-read_csv("nations.csv")
Rows: 5275 Columns: 10
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (5): iso2c, iso3c, country, region, income
dbl (5): year, gdp_percap, population, birth_rate, neonat_mortal_rate
ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
Creating a new variable
nations <- nations %>%mutate(gdp_trillion = gdp_percap * population /10^12)
gg1 <-ggplot(filtered_data, aes(x = year, y = gdp_trillion, color = country)) +geom_point() +geom_line() +scale_color_brewer(palette ="RdPu") +labs(x ="Year", y ="GDP ($ trillions)", title ="GDP Trends Across African Countries Over Time") +theme_minimal()
gg2 <-ggplot(region_gdp, aes(x = year, y = sum_GDP, fill = region)) +geom_area(color ="white", size =0.2) +scale_fill_viridis(discrete =TRUE, option ="magma") +labs(x ="Year", y ="GDP ($ trillion)", title ="GDP by World Bank Region") +theme_minimal()
Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
ℹ Please use `linewidth` instead.