Download and input the Gapminder data set.
dta <- read.csv("https://4va.github.io/biodatasci/data/gapminder.csv")
library(knitr)
kable(head(dta))
country | continent | year | lifeExp | pop | gdpPercap |
---|---|---|---|---|---|
Afghanistan | Asia | 1952 | 28.801 | 8425333 | 779.4453 |
Afghanistan | Asia | 1957 | 30.332 | 9240934 | 820.8530 |
Afghanistan | Asia | 1962 | 31.997 | 10267083 | 853.1007 |
Afghanistan | Asia | 1967 | 34.020 | 11537966 | 836.1971 |
Afghanistan | Asia | 1972 | 36.088 | 13079460 | 739.9811 |
Afghanistan | Asia | 1977 | 38.438 | 14880372 | 786.1134 |
The mean life expectancy is 59.4744394 years.
The years surveyed in this data include: 1952, 1957, 1962, 1967, 1972, 1977, 1982, 1987, 1992, 1997, 2002, 2007.
library(ggplot2)
ggplot(dta, aes(gdpPercap, lifeExp, color = continent)) +
geom_point() +
scale_x_log10() +
labs(x = "GDP", y = "Life Expectancy (years)") +
theme_bw()
Life Exp vs GDP
sessionInfo()
## R version 3.4.3 (2017-11-30)
## Platform: x86_64-w64-mingw32/x64 (64-bit)
## Running under: Windows 7 x64 (build 7601) Service Pack 1
##
## Matrix products: default
##
## locale:
## [1] LC_COLLATE=Chinese (Traditional)_Taiwan.950
## [2] LC_CTYPE=Chinese (Traditional)_Taiwan.950
## [3] LC_MONETARY=Chinese (Traditional)_Taiwan.950
## [4] LC_NUMERIC=C
## [5] LC_TIME=Chinese (Traditional)_Taiwan.950
##
## attached base packages:
## [1] stats graphics grDevices utils datasets methods base
##
## other attached packages:
## [1] ggplot2_2.2.1 knitr_1.20
##
## loaded via a namespace (and not attached):
## [1] Rcpp_0.12.15 digest_0.6.15 rprojroot_1.3-2 plyr_1.8.4
## [5] grid_3.4.3 gtable_0.2.0 backports_1.1.2 magrittr_1.5
## [9] scales_0.5.0 evaluate_0.10.1 pillar_1.2.1 highr_0.6
## [13] rlang_0.2.0 stringi_1.1.6 lazyeval_0.2.1 rmarkdown_1.9
## [17] labeling_0.3 tools_3.4.3 stringr_1.3.0 munsell_0.4.3
## [21] yaml_2.1.17 compiler_3.4.3 colorspace_1.3-2 htmltools_0.3.6
## [25] tibble_1.4.2