Rutherford FMR, by size and ZIP | |||||||
ZIP | Studio | BR1 | BR2 | BR3 | BR4 | ZIP_Average | Rent_Category |
---|---|---|---|---|---|---|---|
37037 | 1660 | 1710 | 1920 | 2410 | 2940 | 2128 | Above average |
37086 | 1580 | 1620 | 1820 | 2290 | 2790 | 2020 | Above average |
37128 | 1510 | 1550 | 1740 | 2190 | 2670 | 1932 | Above average |
37129 | 1420 | 1460 | 1640 | 2060 | 2510 | 1818 | Above average |
37153 | 1410 | 1450 | 1630 | 2040 | 2490 | 1804 | Above average |
37167 | 1290 | 1330 | 1490 | 1870 | 2280 | 1652 | Below average |
37085 | 1260 | 1290 | 1450 | 1820 | 2210 | 1606 | Below average |
37127 | 1240 | 1270 | 1430 | 1800 | 2190 | 1586 | Below average |
37130 | 1180 | 1210 | 1360 | 1710 | 2080 | 1508 | Below average |
37132 | 1180 | 1210 | 1360 | 1710 | 2080 | 1508 | Below average |
37118 | 1100 | 1130 | 1270 | 1590 | 1960 | 1410 | Below average |
37149 | 1100 | 1130 | 1270 | 1590 | 1960 | 1410 | Below average |
Code:
# Getting and 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")
# Showing the rent data
FMR_RuCo_table <- gt(FMR_RuCo) %>%
tab_header("Rutherford FMR, by size and ZIP") %>%
cols_align(align = "left") %>%
gt_theme_538
FMR_RuCo_table
# 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 FMR_RuCo_Map
FMR_RuCo_Map <- st_as_sf(FMR_RuCo_Map)
# Making the map
Rent_Category_Map <- mapview(
FMR_RuCo_Map,
zcol = "BR3",
col.regions = brewer.pal(9,"BuGn"),
layer.name = "Three-bedroom rent",
popup = popupTable(
FMR_RuCo_Map,
feature.id = FALSE,
row.numbers = FALSE,
zcol = c("ZIP", "Studio", "BR1", "BR2", "BR3", "BR4")))
# Showing the map
Rent_Category_Map
# Installing and 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")
if (!require("tidycensus"))
install.packages("tidycensus")
library(tidyverse)
library(gtExtras)
library(sf)
library(mapview)
library(leafpop)
library(RColorBrewer)
library(tidycensus)
census_api_key("93315bc9312a299da799361cc702a29db484d7cd")
Census_Data <- get_acs(
geography = "zcta",
variables = c("DP04_0047", "DP04_0045"),
year = 2023,
survey = "acs5",
output = "wide",
geometry = FALSE
)
Census_Data <- Census_Data %>%
rename(c("Rentals" = "DP04_0047E",
"Rentals_MOE" = "DP04_0047M",
"Households" = "DP04_0045E",
"Households_MOE" = "DP04_0045M"))
glimpse(Census_Data)
FMR_RuCo_Map <- left_join(FMR_RuCo_Map, Census_Data, by = c("ZIP" = "GEOID"))
ZIP_Map <- mapview(
FMR_RuCo_Map,
zcol = "ZIP_Average",
col.regions = brewer.pal(9, "Blues"),
layer.name = "Average rent",
popup = popupTable(
FMR_RuCo_Map,
feature.id = FALSE,
row.numbers = FALSE,
zcol = c("ZIP", "Studio", "BR1", "BR2", "BR3", "BR4",
"Rentals", "Rentals_MOE", "Households", "Households_MOE")
)
)
# Showing the map
ZIP_Map