Answered step by step
Verified Expert Solution
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%")
- Mutate the data frame and convert the"date"column into a numeric value. (Notes: usingas.numeric())
- 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)
- 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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started