2015 US census- counties dataset

Hello there,
I am pretty new to R. I am learning R.
I am not able to access counties data set in R. how can i get it?

Please help !!

1 Like

The {tidycensus} package is a good place to start.
tidycensus website

1 Like

Consider the excellent {tigris} package. It interfaces directly to the US Census Bureau servers. Note however that the shapefiles can be detailed (and rather large as consequence).

For inspiration consider this code:

library(ggplot2)
library(tigris)
library(dplyr)
library(sf)


#download all the counties - incl. AK, HI 
all_counties <- tigris::counties(year = 2015, class = "sf", resolution = "20m")

# lower 48 only
lower_48 <- all_counties %>% 
  filter(STATEFP < "60") %>% # territories out
  filter(!STATEFP %in% c("02", "15")) # AK & HI out

# make a plot to check
ggplot() +
  geom_sf(data = lower_48) +
  coord_sf(crs = 5070) # Albers projection

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.