Question: 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Mathematics Questions!