About packageForGapminder

packageForGapminder is a package which makes model pop/lifeExp/gdpPercap VS year for countries in gapminder dataset easier, as well as makes it possible to use only one line code to help you get a intuitive view on how well pop/lifeExp/gdpPercap and year in gapminder dataset fits a linear model.

To install the package:

library(packageForGapminder)
## load some other packages here
library(knitr)
options(knitr.table.format="markdown")        #Set the format for tables as "markdown"

In this package, we have three functions in total. See below.

Besides, by default, all these three funtions will fit the linear model to data pop VS year for a gapminder country.

Using gapminder_lmfit():

Fit linear model to gapminder country data.

gapminder_lmfit("Canada")                   ##fit a linear model to pop VS year for "Canada"
gapminder_lmfit("Canada","year","lifeExp")  ##fit a linear model to lifeExp VS year for "Canada"
gapminder_lmfit("China","year","gdpPercap") ##fit a linear model to gdpPercap VS year for "China"

Using gapminder_lm_table():

Get the table which compares the actual pop/lifeExp/gdpPercap values with the predicted values that we compute from the linear model.

table1 <- gapminder_lm_table("Canada")
kable(table1)
table2 <- gapminder_lm_table("Canada","year","lifeExp")
kable(table2)
table3 <- gapminder_lm_table("China","year","gdpPercap")
kable(table3)

Using gapminder_lm_plot():

Draw a plot to give you an intuitive view on how well a gapminder country data(pop/lifeExp/gdpPercap VS year) fits a linear model.

gapminder_lm_plot("Canada")
gapminder_lm_plot("Canada","year","lifeExp")
gapminder_lm_plot("China","year","gdpPercap")

packageForGapminder really makes it easier to check the linear relationships between pop/lifeExp/gdpPercap and year for a gapminder country.



LinaQiu/packageForGapminder documentation built on May 8, 2019, 11:20 p.m.