Interactive map of all the ZIP codes in Rutherford County with their respective average 3 bedroom rent prices.

The interactive map shows the average prices for 3 bedroom rental abodes in ZIP codes across Rutherford County. The data, which is the 2024 small-area fair market rent data from the U.S. Department of Housing and Urban Development, may indicate to renters which zip codes have the best value to rent in.

Code:

# Loading required packages
if (!require("tidyverse")) install.packages("tidyverse")
if (!require("gtExtras")) install.packages("gtExtras")
if (!require("leafpop")) install.packages("leafpop")
if (!require("sf")) install.packages("sf")
if (!require("mapview")) install.packages("mapview")
if (!require("RColorBrewer")) install.packages("RColorBrewer")

library(tidyverse)
library(gtExtras)
library(sf)
library(mapview)
library(leafpop)
library(RColorBrewer)

# Reloading the rent data
FMR_RuCo <- read_csv("https://raw.githubusercontent.com/drkblake/Data/refs/heads/main/FMR_RuCo.csv")

# Downloading the ZIP code map file
download.file("https://www2.census.gov/geo/tiger/GENZ2020/shp/cb_2020_us_zcta520_500k.zip","ZCTAs2020.zip")

# Unzipping the ZIP code map file
unzip("ZCTAs2020.zip")

# Loading the ZIP code file into R as "ZCTAMap"
ZCTAMap <- read_sf("cb_2020_us_zcta520_500k.shp")

# Making ZIP a character variable
FMR_RuCo$ZIP <- as.character(FMR_RuCo$ZIP)

# Joining the files
FMR_RuCo_Map <- left_join(FMR_RuCo, ZCTAMap, by = c("ZIP" = "ZCTA5CE20"))

# Dropping unneeded columns 
FMR_RuCo_Map <- FMR_RuCo_Map %>%
  select(-c(AFFGEOID20, GEOID20, NAME20, LSAD20, ALAND20, AWATER20))

# Converting to spatial data frame
FMR_RuCo_Map <- st_as_sf(FMR_RuCo_Map)

# Creating the map for 3-bedroom rent prices
Rent_3BR_Map <- mapview(
  FMR_RuCo_Map,
  zcol = "BR3",  # Using 3-bedroom rent prices
  layer.name = "3-Bedroom Rent Prices",
  col.regions = brewer.pal(9, "YlOrRd"), # Color scheme
  popup = popupTable(
    FMR_RuCo_Map,
    feature.id = FALSE,
    row.numbers = FALSE,
    zcol = c("ZIP", "BR3")))

# Showing the map
Rent_3BR_Map