The Data

The Integrated Public Use Microdata Series (IPUMS) collects, preserves and harmonizes census microdata and provides easy access to this data with enhanced documentation. Data from the U.S. Census and a variety of other sources (Current Population Survey; Demographic and Health Surveys; International Surveys) are available at https://www.ipums.org/. In this design task, you will use International Census data from IPUMS-International, but will restrict your attention to the U.S. alone. The data of interest for this task come in two .csv files. A lot of work has already been done to get these .csv files to their current state.

The IPUMS-Sex-Edattain.csv, gives census counts for each country/year/sex/educational attainment combination. The data set includes counts only for those age 25 or older. “Educational attainment” refers to the highest level of education achieved.

The questions to visualize are as follows:

The goal is to make the answers to the three questions as clear as possible in a single visualization. This includes choosing the best visualization, adding labels and annotations, while also choosing colors and styles that are visually pleasing and accessible.

Here is the original data:

sexed <- read_csv("IPUMS-Sex-EdAttain.csv")
Rows: 2244 Columns: 5
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (3): Country, Sex, EdAttain
dbl (2): Year, Count

ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.

Here are some modifications to the data to help make appropriate comparisons. First, annotate the code to identify what each code is doing.

sex_edu_update <- sexed %>% 
  filter(Country == "United States") %>%  #comment
  mutate(EdAttain = factor(EdAttain, 
                           levels = c("Less than primary completed",
                                      "Primary completed",
                                      "Secondary completed", 
                                      "University completed"))) %>% #comment
  group_by(Year, Sex) %>%   #comment
  mutate(TotalYearGender = sum(Count, na.rm = TRUE)) %>%   #comment
  mutate(Proportion_1 = Count/TotalYearGender)  %>%  #comment
  group_by(Year, EdAttain) %>% #comment
  mutate(TotalYearEdu = sum(Count, na.rm = TRUE)) %>% #comment
  mutate(Proportion_2 = Count/TotalYearEdu) #comment

Why did we perform the calculations above within our data?

We did this to clean data/aggregation and to create the variables needed to even show relations.

Intepret what Proportion_1 and Proportion_2 measure in our data.

Insert Answer Here Proportion is for year and sex variabl measures while proprtion 2 year and edattain.

Visualizations

Now you are going to choose a visualization to modify that you think best helps answer the questions.

Choose the visualization that you think will help you best answer ALL THREE questions at once. Then update the visualization with labels, appropriate colors, annotations, etc. to make the answers to the questions ABSOLUTELY CLEAR. In addition, be sure the data source is identified on the visualization and provide alternative text.

Questions to Answer

Which visualization did you choose and why?

Insert Answer Here

I picked proportions due to it’s sleek look, it’s good for constant values, and

How is your choice of visualization better, compared to the other options, at providing answers to all three questions easily within a single visualization?

Insert Answer Here

Now delete the other visualizations and modify the one you chose with updates, labels, annotations, data sources, etc. to provide clear and concise answers to the three original questions.

Export the image a png file when completed and submit your code, question answers, and png.

Note: If you feel like you might have a better ideas for a visualization other than adapting one of the provided visualizations you are free to create your own instead, but it must meet the same qualifications.

Visualization 1

sex_edu_update %>% 
  ggplot(aes(x = Year, y = Proportion_1, color = Sex)) +
  geom_line() +
  facet_wrap(~EdAttain)

#ggsave()

Visualziation 2

# Rename the EdAttain variable to Education Level Completion
renamed_data <- sex_edu_update %>%
  rename(`Education Level Completion` = EdAttain)

# Plot the data with the renamed variable, different shapes, and density plot
renamed_data %>%
  ggplot(aes(x = Year, fill = `Education Level Completion`, y = Proportion_1, shape = `Education Level Completion`)) +
  labs(y = "Proportion Census 25+ Year Olds",
       x = "Decades") +
  geom_point(position = "fill", size = 3) +  # Use geom_point to specify shapes
  geom_density(position = "fill", stat = "identity", alpha = 0.5) +  # Density plot
  facet_wrap(~Sex) +
  scale_fill_manual(values = c("#094073", "#0f70c9", "#86bbec", "#d8e8f7")) +
  scale_shape_manual(values = c("Low" = 1, "Medium" = 2, "High" = 3, "Very High" = 4)) +  # Specify shape codes
  theme_linedraw() +
  theme(axis.text.x = element_text(angle = 45, hjust = 1))
Warning: Removed 56 rows containing missing values (`geom_point()`).

ggsave("sex_edu_update.png")
Saving 7 x 5 in image
Warning: Removed 56 rows containing missing values (`geom_point()`).
### Visualization 3
#sex_edu_update %>% 
  #ggplot(aes(x = Year, y = Proportion_1, color = EdAttain)) +
  #geom_line() +
  #facet_wrap(~Sex)

#ggsave()

Visualziation 4

sex_edu_update %>% 
  ggplot(aes(x = Year, fill = Sex, y = Proportion_2)) +
  geom_density(position = "fill", stat = "identity") +
  facet_wrap(~EdAttain)

#ggsave()