Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please use R, Working with the World Bank database: https://data.worldbank.org/indicator?tab=all (list of all indicators) library(wbstats) Access and wrangle the data. Save the wrangled data in

Please use R,

Working with the World Bank database:

https://data.worldbank.org/indicator?tab=all

(list of all indicators)

library("wbstats")

Access and wrangle the data. Save the wrangled data in a data frame called"usa_income_by_year"

  • Use thewb_data()function to access data for the following indicators for country "USA" for the 20 most recent years: "Income share held by highest 10%", "Income share held by lowest 20%", and "Income share held by second 20%". (Notes: use"USA"as thecountryargument, need to look up their IDs). ID:SI.DST.10TH.10("Income share held by highest 10%"), ID:SI.DST.FRST.20 ("Income share held by lowest 20%"), ID:SI.DST.02ND.20 ("Income share held by second 20%")
  1. Mutate the data frame and convert the"date"column into a numeric value. (Notes: usingas.numeric())
  2. Mutate the data frame and create two new columns. The first one: "top_10%" (Top 10% of income (wealth)). The second one: "bottom_40%" (40% of the lowest income (wealth), which means add the lowest and second-lowest 20% together)
  3. Pivotthis data intothe longformat,Collect the values of the two columns ("top_10%" and "bottom_40%") into one column.

In the end, the data frame should have 40 rows; 1 for each year and category (first 10% or bottom 40%)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

High School Math 2012 Common-core Algebra 2 Grade 10/11

Authors: Savvas Learning Co

Student Edition

9780133186024, 0133186024

More Books

Students also viewed these Mathematics questions