library(readr)
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
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(tidyverse)
## -- Attaching packages -------------------------------------------------------------------------------- tidyverse 1.2.1 --
## v tibble 2.1.3 v purrr 0.3.2
## v tidyr 1.0.0 v stringr 1.4.0
## v tibble 2.1.3 v forcats 0.4.0
## -- Conflicts ----------------------------------------------------------------------------------- tidyverse_conflicts() --
## x plotly::filter() masks dplyr::filter(), stats::filter()
## x dplyr::lag() masks stats::lag()
As with the first chart, I didn’t really know where to begin with mutating in dplyr. However, this csv manipulation in Excel took a lot longer than I expected, so now I understand why R might be a more useful tool in many instances. (Unfortunately I don’t feel capable enough in R at the moment, so Excel it is…)
setwd("C:/Users/Don A/Documents/Don's files/MC")
week7hw2 <- read_csv("nations2b.csv")
## Parsed with column specification:
## cols(
## year = col_double(),
## region = col_character(),
## gdpt = col_double()
## )
Lots of trial and error with this one – and this is as close as I could get…
ggplot(data = week7hw2) +
geom_area(mapping = aes(x = year, y = gdpt, group = region, color = region )) +
ggtitle("GDP by World Bank Region") +
labs(x = "year", y = "GDP ($ trillions)") +
scale_fill_brewer(palette = "Sets")
## Warning in pal_name(palette, type): Unknown palette Sets