This is an R Markdown Notebook. When you execute code within the notebook, the results appear beneath the code.

Try executing this chunk by clicking the Run button within the chunk or by placing your cursor inside it and pressing Ctrl+Shift+Enter.

sapply(c('tidycensus','here','tidyverse'), require, character.only=T)
knitr::opts_knit$set(root.dir = here())
racevars <- c('P005001','P005010','P005003','P005004','P005006','P005005')
bay_counties <- c("001", "013", "041", "055", "075", "081", "085", "095",
  "097")
data <- get_decennial(geography = 'tract',variables = racevars,state=6,county=bay_counties, output = 'wide')

Rename and format data

bay_race <- transmute(data,fips=GEOID, total_pop    =   P005001, hispanic   =   P005010,
  white =   P005003, black  =   P005004, asian  =   P005006, 
  all_other = total_pop - white-black-hispanic-asian,
  county =gsub('^[^,]+, ','',NAME), county=paste0(county, ", 2010"))

For now, I only want to save the wide format

usethis::use_data(bay_race, overwrite=T)


arthurgailes/rsegregation documentation built on May 23, 2021, 6:33 a.m.