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.
nations_gdp <- nations |>mutate(gdp_trillions = gdp_percap * population /10^12)
gdp_trillions_4 <- nations_gdp |>filter(country =="Brazil"| country =="Portugal"| country =="Sweden"| country =="South Africa")
p1 <- gdp_trillions_4 |>ggplot() +geom_point(aes(x = year, y = gdp_trillions, color = country)) +scale_color_brewer(palette ="Set1") +geom_line(aes(x = year, y = gdp_trillions, color = country)) +labs(title ="GDP of Brazil, Portugal, South Africa, and Sweden", x ="Year",y ="GDP in Trillions",caption ="Citations: https://ggplot2-book.org/themes.html, https://www.statology.org/hjust-vjust-ggplot2/",color ="Country") +theme_classic(base_size =12) +theme(plot.title =element_text(hjust =0.5)) +theme(legend.position =c(1, 1))
Warning: A numeric `legend.position` argument in `theme()` was deprecated in ggplot2
3.5.0.
ℹ Please use the `legend.position.inside` argument of `theme()` instead.
── 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.
nations <- nations |>mutate(gdp_trillions = (gdp_percap * population /10^12))