Economics Data Visualization of GDP Data
ECON 4331W – Assignment 1 Written by: Hannes Malmberg Updated on 09/12/2023 Data visualization of GDP data We have discussed the evolution of material living standards over time and across countries. In this exercise, you will do independent work on data on GDP per capita, a standard measure of living standards. You should submit a zipped-folder with your assignment. The zip folder be named FirstName_LastName_A1.zip. It should contain • The script with your code, “FirstName_LastName_A1.R” • An .Rproj file called “FirstName_LastName_A1.Rproj” (this will simply be a link to ensure that the grader sets it up in the right folder, see Chapter 8 in “R for Data Science”) • A pdf file with the answers to all the exercises, “FirstName_LastName_A1.pdf.” This file should include written answers to each question (in English, no code) and/or the graphs that the exercise is asking you to generate. You are responsible for naming your files appropriately, and that the code should run without errors. The exercise uses R. For instructions on how to get started with R, please refer to Section 1.4-1.6 in “R for Data Science”. This exercise is a re-write of Chapter 3 in “R for Data Science” using other examples. If you are interested in the orignal resource, you can find it at http://r4ds.had.co.nz/data-visualisation.html Introduction “The simple graph has brought more information to the data analyst’s mind than any other device.” — John Tukey This exercise will teach you how to visualize your data using ggplot2. R has several systems for making graphs, but ggplot2 is one of the most elegant and most versatile. The ggplot2 package implements the grammar of graphics, a coherent system for describing and building graphs. With ggplot2, you can do more faster by learning one system and applying it in many places. If you’d like to learn more about the theoretical underpinnings of ggplot2 before you start, I’d recommend reading “The Layered Grammar of Graphics”, http://vita.had.co.nz/papers/layered-grammar.pdf. Prerequisites The ggplot2 package is one of the packages in “tidyverse”, a collection of packages created by Hadley Wickman to do data science in R. To load tidyverse, write 1 library(tidyverse) That one line of code loads the core tidyverse; packages which you will use in almost every data analysis. If you run this code and get the error message ‘there is no package called “tidyverse” ’, you’ll need to first install it, then run library() once again. install.packages(“tidyverse”) library(“tidyverse”) You only need to install a package once, but you need to reload it every time you start a new session. First steps Let’s use our first graph to answer a question: Do countries with higher income levels have a longer life expectancy than countries with low income levels? You probably already have an answer, but try to make your answer precise. What does the relationship between income levels and life expectancy look like? Is it positive? Negative? Linear? Nonlinear? The Gapminder data You can test your answer using data from Gapminder. Gapminder is a foundation that works on making data on development broadly accessible. Gapminder has data on GDP per capita data taken from the Penn World Table (PWT), the data source that we talked about in lectures. R has a custom-designed package to access the Gapminder data on GDP per capita and life expectancy. Install the gapminder package as we did above and then load it by writing the following command: library(“gapminder”) Loading this package gives us access to the gapminder data frame. A data frame is a rectangular collection of variables (in the columns) and observations (in the rows). gapminder contains observations collected by the Gapminder on GDP per capita and life expectancy in a selection of countries for different years. Print the data frame by writing: gapminder ## # A tibble: 1,704 x 6 ## country continent year lifeExp pop gdpPercap ## ## 1 Afghanistan Asia 1952 28.8 8425333 779. ## 2 Afghanistan Asia 1957 30.3 9240934 821. ## 3 Afghanistan Asia 1962 32.0 10267083 853. ## 4 Afghanistan Asia 1967 34.0 11537966 836. ## 5 Afghanistan Asia 1972 36.1 13079460 740. ## 6 Afghanistan Asia 1977 38.4 14880372 786. ## 7 Afghanistan Asia 1982 39.9 12881816 978. ## 8 Afghanistan Asia 1987 40.8 13867957 852. ## 9 Afghanistan Asia 1992 41.7 16317921 649. ## 10 Afghanistan Asia 1997 41.8 22227415 635. ## # i 1,694 more rows 2 To learn more about gapminder, open its help page by running ?gapminder. In our exercise, we will start by focusing on the latest set of observations from 2007. To restrict attention to these observations, run the code gapminder07
Collepals.com Plagiarism Free Papers
Are you looking for custom essay writing service or even dissertation writing services? Just request for our write my paper service, and we'll match you with the best essay writer in your subject! With an exceptional team of professional academic experts in a wide range of subjects, we can guarantee you an unrivaled quality of custom-written papers.
Get ZERO PLAGIARISM, HUMAN WRITTEN ESSAYS
Why Hire Collepals.com writers to do your paper?
Quality- We are experienced and have access to ample research materials.
We write plagiarism Free Content
Confidential- We never share or sell your personal information to third parties.
Support-Chat with us today! We are always waiting to answer all your questions.