Variable | Description |
---|---|
group.f | Mutually exclusive income groups based on total income for 2022 for all U.S. adults. The groups include: 1. The bottom 50% of income earners (0th to the 50th percentile), 2. The middle 40% of income earners (50th percentile to the 90th percentile), 3. The top 10% (excluding the top 1%), 4. The top 1% (excluding the top .1%), 5. The top .1% (excluding the top .01%), and 6. The top .01% |
population | The total number of people in the group. |
factor_income_share | The proportion of total income that belongs to the group. Income can come from several sources, such as wages, salaries, interests, dividends, and rents. For this study it includes all labor and capital income before taxes. |
wealth_share | The proportion of total wealth that belongs to the group. Wealth includes all assets individuals own, such as houses, cars, savings, retirement accounts, and investments, minus their debts like mortgages and student loans. Wealth, therefore, represents the accumulation of resources over time and is more related to long-term financial security and opportunity. For this study wealth includes all financial and non-financial assets owned by households, net of all debts. Assets include all funded pensions (IRAs, 401(k)s, and funded defined benefits pensions). Vehicles and unfunded pensions (such as promises of future Social Security benefits and other unfunded defined benefits pensions) are excluded. |
Apply and Practice Activity
Wealth Inequality
Introduction
In Module 3: Data Visualization, we used the Realtime Inequality data compiled by Drs. Thomas Blanchet, Emmanuel Saez, and Gabriel Zucman of the Department of Economics, University of California, Berkeley.
The data are compiled in the data frame called real_time_ineq_2022.Rds — hosted in the data folder of the foundations project in the Posit Cloud. The data were downloaded from the Realtime Inequality website in May of 2023. The following variables are included in the data frame:
Your activity
In Module 3, we created a bar graph to depict income inequality (using factor_income_share as the primary variable). Now, I’d like for you to re-produce the graph, but consider wealth inequality (wealth_share) rather than income inequality (factor_income_share).
The variable wealth_share is similar to the variable that we considered in Module 3, (factor_income_share), but it presents the share of wealth belonging to each group rather than income. While income and wealth are related, they are not the same. A person might have a high income but also have high debts, leading to a low level of wealth. On the other hand, someone could have a modest income but, through savings and investments, accumulated a high level of wealth. Both income and wealth inequalities are significant when considering economic inequality as they influence opportunities, living standards, and power dynamics within society. However, wealth inequality is usually much greater than income inequality. This is because wealth can accumulate over generations and can result in entrenched economic disparities.
Please follow the steps below to complete this activity.
Step by step directions
Step 1
Navigate to the apply_and_practice_programs folder in the programs folder of the foundations project in the Posit Cloud. Open up the file called wealth_inequality.qmd.
To ensure you are working in a fresh session, close any other open tabs (save them if needed). Click the down arrow beside the Run button toward the top of your screen then click Restart R and Clear Output.
Step 2
In the YAML header, add your name — be sure to leave the quotations and don’t add anything additional (e.g., extra spaces, tabs, etc.).
Step 3
Run the code chunk to load the needed packages.
library(here)
library(tidyverse)
Notice the comment:
#| message: false
This is a code block direction to suppress the messages produced when the packages load. We’ll learn more about these later. You always want to make sure these code block directions are at the very top of the code chunk.
Step 4
Run the code chunk to import the data frame. The first line of code imports the data. The second line of code requests that the data frame be printed below the code chunk (so you can take a look at it).
<- read_rds(here("data", "real_time_ineq_2022.Rds"))
real_time_ineq_2022 real_time_ineq_2022
Notice the variable called group.f — that is the grouping variable we will consider for the graph. Also notice the variable called wealth_share — that is the wealth variable that we will consider across our groups.
Step 5
Create the graph.
Under the section “Create the bar graph” — complete the code to create a vertical bar graph of wealth inequality.
- Map group.f to the x-axis and wealth_share to the y-axis. Replace these names with the XXX placeholders.
- Select a color for the bars that you like from this list. Note the color name (e.g., aquamarine) — then input that color name on the
geom_col()
line — that is, replace the XXX placeholder. - Add a suitable title: under
labs()
, change title = “XXX”. - Add a suitable label for the y-axis: under
labs()
, change y = “XXX”. - Run the code chunk to create the graph.
|>
real_time_ineq_2022 ggplot(mapping = aes(x = XXX, y = XXX)) +
geom_col(fill = "XXX") +
scale_y_continuous(label = scales::percent_format(), limits = c(0,.5)) +
geom_text(mapping = aes(label = scales::percent(wealth_share)), hjust = -.1) +
coord_flip() +
labs(title = "XXX",
y = "XXX",
x = "") +
theme_bw()
Step 6
Now that you’ve completed all tasks, to help ensure reproducibility, click the down arrow beside the Run button toward the top of your screen then click Restart R and Clear Output. Scroll through your notebook and see that all of the output is now gone. Now, click the down arrow beside the Run button again, then click Restart R and Run All Chunks. Scroll through the file and make sure that everything ran as you would expect. You will find a red bar on the side of a code chunk if an error has occurred. Taking this step ensures that all code chunks are running from top to bottom, in the intended sequence, and producing output that will be reproduced the next time you work on this project.
Now that all code chunks are working as you’d like, click Render. This will create an .html output of your report. Scroll through to make sure everything is correct. The .html output file will be saved along side the corresponding .qmd notebook file.
Step 7
Follow the directions on Canvas for the Apply and Practice Assignment entitled “Wealth Inequality Apply and Practice Activity” to get credit for completing this assignment.
You can use a slick package called patchwork to combine two plots onto one display. See the code chunk below for a quick demonstration. Later in the course, we’ll discover other methods of creating a single graph that displays data on two different variables simultaneously.
# assign the name income to the income graph
<-
income |>
real_time_ineq_2022 ggplot(mapping = aes(x = group.f, y = factor_income_share)) +
geom_col(fill = "cadetblue") +
scale_x_discrete(labels = scales::wrap_format(10)) +
scale_y_continuous(label = scales::percent_format(), limits = c(0,.5)) +
geom_text(mapping = aes(label = scales::percent(factor_income_share)), vjust = -0.5) +
labs(title = "Income inequality",
y = "% of total income belonging to each group",
x = "") +
theme_minimal()
# assign the name wealth to the wealth graph
<-
wealth |>
real_time_ineq_2022 ggplot(mapping = aes(x = group.f, y = wealth_share)) +
geom_col(fill = "darkgoldenrod2") +
scale_x_discrete(labels = scales::wrap_format(10)) +
scale_y_continuous(label = scales::percent_format(), limits = c(0,.5)) +
geom_text(mapping = aes(label = scales::percent(wealth_share)), vjust = -0.5) +
labs(title = "Wealth inequality",
y = "% of total wealth belonging to each group",
x = "") +
theme_minimal()
library(patchwork)
# specify layout
<- income + wealth
layout
# add common titles
+ plot_annotation(
layout title = "Share of income (on left) and wealth (on right) belonging to each income group",
subtitle = "2022 income and wealth data from U.S. adults",
caption = "Data retrieved from Realtime Inequality (https://realtimeinequality.org)"
)