library(tidyverse)
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.2 ──
## ✔ ggplot2 3.3.6 ✔ purrr 0.3.5
## ✔ tibble 3.1.8 ✔ dplyr 1.0.10
## ✔ tidyr 1.2.1 ✔ stringr 1.4.1
## ✔ readr 2.1.3 ✔ forcats 0.5.2
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
library(readr)
library(knitr)
library(ggplot2)
popdata <- read.csv("~/Documents/Canadapopulationdata.csv")
popdata <- popdata %>% drop_na()
MacroTrends provides over 200,000 data charts about population, education, labor force, birth rate, etc. for nations around the world. This website also provides predictions for future numbers such as projected population and population change. Original data can be found at https://www.macrotrends.net/countries/CAN/canada/population
head(popdata)
## date X.Population X.Annual.Percent.Change
## 1 1951 14085724 2.49
## 2 1952 14485745 2.84
## 3 1953 14901525 2.87
## 4 1954 15323201 2.83
## 5 1955 15733923 2.68
## 6 1956 16167047 2.75
options(scipen = 999)
names(popdata) <- c("date", "population", "annual.percent.change")
ggplot(data = popdata[0:72, ]) +
geom_line(mapping = aes(x = date,y = population), stat = "identity", position = "dodge") + ggtitle("Canada Population 1951-2022") + labs(x = "Date", y = "Population") + theme(plot.title = element_text(hjust = .1))
ggplot(data = popdata[0:72, ]) +
geom_line(mapping = aes(x = date,y = annual.percent.change), stat = "identity", position = "dodge") + ggtitle("Canada Population Percent Change 1951-2022") + labs(x = "Date", y = "Population") + theme(plot.title = element_text(hjust = .1))
knitr::kable(popdata[80:89, ], caption = "Projected Canadian Population and Percent Change in The 2030's")
| date | population | annual.percent.change | |
|---|---|---|---|
| 80 | 2030 | 41008596 | 0.76 |
| 81 | 2031 | 41319872 | 0.76 |
| 82 | 2032 | 41626319 | 0.74 |
| 83 | 2033 | 41926289 | 0.72 |
| 84 | 2034 | 42218806 | 0.70 |
| 85 | 2035 | 42503204 | 0.67 |
| 86 | 2036 | 42780162 | 0.65 |
| 87 | 2037 | 43051176 | 0.63 |
| 88 | 2038 | 43315598 | 0.61 |
| 89 | 2039 | 43572770 | 0.59 |
I chose to study the Canadian population and population change because Canada is my home country. I have studied in the United States since 2017, my sophomore year of high school, but I still spend my summers at home in Canada. Over the years, I have noticed my hometown, Burlington Ontario, become increasingly busy both on the roads and around public areas. My findings were then backed up by the data I found as the first graph portraying the population in Canada has a severely positive slope, showing an increase in the population of the country.
Some difficulties I had included transferring my data into a usable CSV, that I then could transfer into my RMD. Previous assignments have had CSV links already created, thus making the data import very straight forward. However, I had to create the CSV file, then transfer it into my assignment using the correct code in order to source it from the correct location on my computer. This required some research on the proper syntax on how to fetch the data, which took some time, but I was able to figure it out.