2

I'm comparing racial composition and area median income over time in one area (can do either census tract or ZCTA. Here I'll include ZCTA because the MOE isn't as large).

What is the best format to put my data into so that I can visualize it? Also, how do I calculate each racial/ethnic group as a percentage of the total, and percent change?

I was able to use dplyr (spread) for YEAR and ESTIMATE, but I want to also be able to do that for YEAR and MOE. Is this even the right move?

I also want to calculate the percentage of each racial/ethnic group, and the percent change. How do I do this?

Thank you!

Here, I figured out how to pull the data for multiple years:

library(tidyverse)
library(tidycensus)

years <- lst(2012, 2017)
race_ethnicity <- c(Total = "DP05_0070", Hispanic = "DP05_0071", White = "DP05_0077", Black = "DP05_0078")

multi_yearZCTA <- map_dfr(
  years,
  ~get_acs(
    geography = "zcta",
    variables = race_ethnicity,
    year = .x,
    survey = "acs5",
    geometry = FALSE
  ),
  .id = "years"
) %>%
  arrange(variable, NAME) %>%
  print()

And then I selected the specific ZCTA...

# Select specific ZCTA
RundbergZCTA <- multi_yearZCTA %>%
  filter(NAME == "ZCTA5 78758")

I can spread but it doesn't carry the MOE...

RundbergZCTA2 <- RundbergZCTA %>%
  spread(years, estimate, sep = "_")

But I'm not really sure where to go from there.

william3031
  • 1,653
  • 1
  • 18
  • 39
Lizzie
  • 21
  • 3

0 Answers0