-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgapminder_analyses_demo.Rmd
78 lines (52 loc) · 1.66 KB
/
gapminder_analyses_demo.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
---
title: "Gapminder_analysis_demo"
author: "Sarah Sutton"
date: "October 4, 2015"
output: html_document
---
```{r, echo=FALSE}
#install.packages("dplyr")
library("dplyr")
```
Load the data file, select three countries and make scatter plots of their GDP vs. year.
```{r read-in-data, echo=FALSE}
gap.in <- read.table("output/combined_gapMinder.tsv", sep = "\t", header=TRUE)
filter(gap.in, country == "China") -> china
plot(china$year,
china$gdpPercap,
xlab="Year",
ylab="GDP",
main="China")
filter(gap.in, country == "Brazil") -> brazil
plot(brazil$year,
brazil$gdpPercap,
xlab="Year",
ylab="GDP",
main="Brazil")
filter(gap.in, country == "Zimbabwe") -> zim
plot(zim$year,
zim$gdpPercap,
xlab="Year",
ylab="GDP",
main="Zimbabwe")
```
*China's* GDP seems to take an exponential growth curve.
*Brazil's* GDP takes a steep upturn in the 1970's, and then the growth rate slows, but continues to increase.
*Zimbabwe's* GDP rises sharply in the 70's, then is quite erratic before plummeting in the 90's.
```{r aggregate-data, echo=FALSE}
head(summarise(group_by(gap.in, continent),
mean_pop = mean(pop),
min_pop = min(pop),
max_pop = max(pop)))
```
The above table shows that Africa's population grew a lot.
```{r life_expectancy, echo=FALSE}
hist(gap.in$lifeExp,
xlab = "Age",
main = "Life Expectancy")
hist(gap.in$lifeExp,
xlab = "Age",
breaks = 26,
main = "Life Expectancy")
```
The narrower breaks for the histogram of life expectancy shows the stronger bimodal distribution with a peak at 44 years of age and a higher peak at 72.