# A tibble: 4,509 × 5
gdp_percap population year country GDP
<dbl> <dbl> <dbl> <chr> <dbl>
1 73037. 1913190 1991 United Arab Emirates 0.140
2 71960. 2127863 1993 United Arab Emirates 0.153
3 83534. 3217865 2001 United Arab Emirates 0.269
4 73154. 2019014 1992 United Arab Emirates 0.148
5 74684. 2238281 1994 United Arab Emirates 0.167
6 75427. 6010100 2007 United Arab Emirates 0.453
7 87844. 3975945 2004 United Arab Emirates 0.349
8 79480. 2467726 1996 United Arab Emirates 0.196
9 82754. 5171255 2006 United Arab Emirates 0.428
10 84975. 3050128 2000 United Arab Emirates 0.259
# ℹ 4,499 more rows
# A tibble: 6 × 5
region population year gdp_percap GDP
<chr> <dbl> <dbl> <dbl> <dbl>
1 Middle East & North Africa 1913190 1991 73037. 0.140
2 Middle East & North Africa 2127863 1993 71960. 0.153
3 Middle East & North Africa 3217865 2001 83534. 0.269
4 Middle East & North Africa 2019014 1992 73154. 0.148
5 Middle East & North Africa 2238281 1994 74684. 0.167
6 Middle East & North Africa 6010100 2007 75427. 0.453
Lets group by it all in the regions they are a part of and there year for us to see the time trend:
# A tibble: 4,509 × 5
# Groups: region, year [175]
region population year gdp_percap GDP
<chr> <dbl> <dbl> <dbl> <dbl>
1 Middle East & North Africa 1913190 1991 73037. 0.140
2 Middle East & North Africa 2127863 1993 71960. 0.153
3 Middle East & North Africa 3217865 2001 83534. 0.269
4 Middle East & North Africa 2019014 1992 73154. 0.148
5 Middle East & North Africa 2238281 1994 74684. 0.167
6 Middle East & North Africa 6010100 2007 75427. 0.453
7 Middle East & North Africa 3975945 2004 87844. 0.349
8 Middle East & North Africa 2467726 1996 79480. 0.196
9 Middle East & North Africa 5171255 2006 82754. 0.428
10 Middle East & North Africa 3050128 2000 84975. 0.259
# ℹ 4,499 more rows
`summarise()` has grouped output by 'region'. You can override using the
`.groups` argument.
nations_selected2
# A tibble: 175 × 3
# Groups: region [7]
region year GDP_total
<chr> <dbl> <dbl>
1 East Asia & Pacific 1990 5.52
2 East Asia & Pacific 1991 6.03
3 East Asia & Pacific 1992 6.50
4 East Asia & Pacific 1993 7.04
5 East Asia & Pacific 1994 7.64
6 East Asia & Pacific 1995 8.29
7 East Asia & Pacific 1996 8.96
8 East Asia & Pacific 1997 9.55
9 East Asia & Pacific 1998 9.60
10 East Asia & Pacific 1999 10.1
# ℹ 165 more rows
Graph
Finaly we can plot a graph tha lets us see the global gpd divided by each region
GDPs_chart2 <-ggplot(nations_selected2, aes(x = year, y = GDP_total, group=region, fill= region, color='White')) +labs(title ="GDP by world Bank Region") +geom_area(color='white') +#here we put in the white shadesxlab("Year") +ylab("GDP ($Trillions)") +scale_fill_brewer(palette ="Set2")GDPs_chart2