Suggested Citation:

Mendez Carlos (2020). An interactive exploration of panel data: Using the package ExPanDaR to generate interactive web applications. R Studio/RPubs. Available at https://rpubs.com/quarcs-lab/explore-panel-interactively

This work is licensed under the Creative Commons Attribution-Share Alike 4.0 International License.

1 Load the data

Let us use the gapminder data set:

Gapminder Data: Life Expectancy and GDP per capita across countries from 1952 to 2007

Documentation of the gapminder dataset

2 Transform the data

  • Take the log of GDP

  • Re-scale the population variable

3 Order and select variables

  • The order of the variables is important

4 Import dataframe of definitions

7 Research Tasks

  • Evaluate the relationship between life expectancy and log of GDP per capita in the years 1952, 1972, and 1992. How does this relationship change over time?

  • Create an interactive web application of your analysis.

  • Read the following tutorial and explore the relationship between GDP per capita and CO2 emission across countries and over time

LS0tCnRpdGxlOiAiQW4gaW50ZXJhY3RpdmUgZXhwbG9yYXRpb24gb2YgcGFuZWwgZGF0YSIKc3VidGl0bGU6ICJVc2luZyB0aGUgcGFja2FnZSBFeFBhbkRhUiB0byBnZW5lcmF0ZSBpbnRlcmFjdGl2ZSB3ZWIgYXBwbGljYXRpb25zIgphdXRob3I6ICJDYXJsb3MgTWVuZGV6IgpvdXRwdXQ6IAogIGh0bWxfbm90ZWJvb2s6CiAgICB0b2M6IHRydWUKICAgIHRvY19mbG9hdDoKICAgICAgY29sbGFwc2VkOiBmYWxzZQogICAgICBzbW9vdGhfc2Nyb2xsOiBmYWxzZQogICAgdG9jX2RlcHRoOiA0CiAgICBudW1iZXJfc2VjdGlvbnM6IHRydWUKICAgIGNvZGVfZm9sZGluZzogInNob3ciCiAgICB0aGVtZTogImNvc21vIgogICAgaGlnaGxpZ2h0OiAibW9ub2Nocm9tZSIKICAgIGRmX3ByaW50OiAia2FibGUiCiAgZ2l0aHViX2RvY3VtZW50OiBkZWZhdWx0Ci0tLQoKPHN0eWxlPgpoMS50aXRsZSB7Zm9udC1zaXplOiAxOHB0OyBjb2xvcjogRGFya0JsdWU7fSAKYm9keSwgaDEsIGgyLCBoMywgaDQge2ZvbnQtZmFt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