Rent is expensive right now. Everyone knows that. But exactly how expensive? Where might the best apartment deals be found? And how would you know whether a place that seems like a bargain really is?
Answers to questions like these have real value, and you can earn a pretty good living by ferreting them out. This course can introduce you to the skills you will need.
Lots. For example, running this code in R - an open-source, free-to-use data analysis package - will retrieve the federal Department of Housing and Urban Development’s latest “Fair Market Rent” estimates for every ZIP code in Tennessee and filter for the dozen ZIP codes that lie entirely or mostly within Rutherford County. Without going into a bunch of detail: Fair Market Rent estimates reflect the typical rents in a given area and are used to help set federal housing subsidy amounts.
In the course, you wouldn’t have to type every line of this code from scratch. Instead, I would give it to you. You’d merely have to copy and paste it, and maybe edit a line or two.
# Installing required packages
if (!require("dplyr")) install.packages("dplyr")
if (!require("tidyverse")) install.packages("tidyverse")
if (!require("mapview")) install.packages("mapview")
if (!require("leaflet")) install.packages("leaflet")
if (!require("leaflet.extras2")) install.packages("leaflet.extras2")
if (!require("tidycensus")) install.packages("tidycensus")
if (!require("sf")) install.packages("sf")
if (!require("openxlsx")) install.packages("openxlsx")
if (!require("scales")) install.packages("scales")
if (!require("leaflet.extras2")) install.packages("leaflet.extras2")
library(dplyr)
library(tidyverse)
library(ggplot2) #From the tidyverse package
library(readr) #From the tidyverse package
library(leaflet)
library(tidycensus)
library(sf)
library(mapview)
library(openxlsx)
library(leaflet.extras2)
library(leafpop)
library(scales)
options(tigris_use_cache = TRUE)
options(scipen = 999)
ZIPList <- c("37127",
"37128",
"37129",
"37130",
"37132",
"37085",
"37118",
"37149",
"37037",
"37153",
"37167",
"37086")
FMR = read.xlsx("https://www.huduser.gov/portal/datasets/fmr/fmr2023/fy2023_safmrs_revised.xlsx",sheet=1)
FMR <- FMR[FMR$ZIP.Code %in% ZIPList,]
keepvars <- c("ZIP.Code",
"SAFMR.0BR",
"SAFMR.1BR",
"SAFMR.2BR",
"SAFMR.3BR",
"SAFMR.4BR")
FMR <- FMR[keepvars]
colnames(FMR) <- c("ZIP",
"Studio",
"BR1",
"BR2",
"BR3",
"BR4")
FMR$Zero_BR <- FMR$Studio
FMR$One_BR <- FMR$BR1
FMR$Two_BR <- FMR$BR2
FMR$Three_BR <- FMR$BR3
FMR$Four_BR <- FMR$BR4
FMR$Studio <- dollar(FMR$Studio)
FMR$BR1 <- dollar(FMR$BR1)
FMR$BR2 <- dollar(FMR$BR2)
FMR$BR3 <- dollar(FMR$BR3)
FMR$BR4 <- dollar(FMR$BR4)
Next, we get a digital ZIP code map from the U.S. Census Bureau and filter it for just the dozen ZIP codes that lie entirely or mostly within Rutherford County.
ZCTAMap <- get_acs(geography = "zcta",
variables = c(Population = "B01001_001"),
year = 2021,
survey = "acs5",
output = "wide",
geometry = TRUE)
# Filtering and formatting the map data
RCMap <- ZCTAMap[ZCTAMap$GEOID %in% ZIPList,]
RCMap <- rename(RCMap, ZIP = GEOID)
Next step: Merge the rent data file and the map file:
RCMap_plus <- RCMap %>%
left_join(FMR, by = c("ZIP" = "ZIP"))
… then tell R to draw the map, color coding each ZIP code by its two-bedroom rent estimate. Note that the map is “live.” You can zoom the map in or out and pan in any direction. Also, if you click on a ZIP code, you’ll see the typical rent in that ZIP code for a range of apartment sizes:
mapviewOptions(basemaps.color.shuffle = FALSE)
ZIPMap <- mapview(RCMap_plus, zcol = "Two_BR",
col.regions = RColorBrewer::brewer.pal(9, "Blues"), alpha.regions = .5,
layer.name = "2 BR Fair Market Rent",
popup = popupTable(RCMap_plus,
feature.id = FALSE,
row.numbers = FALSE,
zcol = c("ZIP",
"Studio",
"BR1",
"BR2",
"BR3",
"BR4")))
ZIPMap
While you’re at it, you might tell R to make a nice chart showing each ZIP code’s typical two-bedroom rent:
ggplot(RCMap_plus,
aes(x = reorder(ZIP, Two_BR), y=BR2))+
geom_bar(stat="identity",
fill="steelblue")+
coord_flip()+
geom_text(aes(label=BR2), hjust=1.5, color="white",
position = position_dodge(0.9), size=3.5)+
labs(x ="ZIP code", y = "Rent")
R will run all of this code in under 15 seconds. And, that quickly, you can have just about everything you need to begin publishing answers to those questions about how high rent actually is, where the good deals might be, and what a good deal might look like.
Here’s an example showing what the map looks like when embedded in a story on my WordPress-based website:
Knowing how to do things like this can be powerful, whether you’re in journalism, public relations, advertising, marketing, or anything else that involves extracting insights from data and sharing those insights with an audience.
The course requires no previous experience with data analysis or coding. We’ll start with the most basic basics. You don’t even have to be good at math, because your computer is going to handle all the math for you.
We’ll ease into spreadsheet techniques using Google’s free, fully online, and surprisingly capable Google Sheets app. It’s like Microsoft Excel, but it runs in a Web browser. In addition to handling calculations way faster and more efficiently than that pocket calculator riding around in the bottom of your backpack, Google Sheets can make awesome interactive graphics and can merge, sort, filter and summarize datasets. Paired with another app from the Google family, Google My Maps, it also can create online, interactive, embeddable maps.
Once you have the fundamentals of Google Sheets and Google My Maps down pat, we’ll look at using R to do the sorts of things shown above. We’ll cover rent, U.S. Census Bureau data, crime incidents, structurally deficient bridges, and more. Class sessions will be hands-on and collaborative (no group projects, though). D2L guides, YouTube tutorials and plenty of examples will help you follow along. Deadlines will matter, but I prefer small, frequent, in-class assessments over a few big, high-stakes projects or exams.
By the end of the course, you’ll have some impressive work for your professional portfolio and everything you’ll need to keep learning more on your own.
A former newspaper reporter, I came to MTSU in 1996 after earning my Ph.D. at the University of North Carolina, Chapel Hill. I’ve been teaching this stuff ever since, and I know what I’m doing. You can learn more about me at drkblake.com. Also: Ask around about me. Look up my ratings online. Come talk to me, even.
I hope to see you in class.