Roughly how much does a typical two-bedroom rental home cost per month in the 37130 ZIP code that surrounds MTSU’s campus? One way to get a good indication is to consult the latest Small Area Fair Market Rent estimates put out by the U.S. Department of Housing and Urban Development.
Here are the 2024 estimates for various rental home sizes in each of the major ZIP codes across Rutherford County:
Rutherford FMR, by size and ZIP | |||||
ZIP | Studio | BR1 | BR2 | BR3 | BR4 |
---|---|---|---|---|---|
37037 | 1660 | 1710 | 1920 | 2410 | 2940 |
37085 | 1260 | 1290 | 1450 | 1820 | 2210 |
37086 | 1580 | 1620 | 1820 | 2290 | 2790 |
37118 | 1100 | 1130 | 1270 | 1590 | 1960 |
37127 | 1240 | 1270 | 1430 | 1800 | 2190 |
37128 | 1510 | 1550 | 1740 | 2190 | 2670 |
37129 | 1420 | 1460 | 1640 | 2060 | 2510 |
37130 | 1180 | 1210 | 1360 | 1710 | 2080 |
37132 | 1180 | 1210 | 1360 | 1710 | 2080 |
37149 | 1100 | 1130 | 1270 | 1590 | 1960 |
37153 | 1410 | 1450 | 1630 | 2040 | 2490 |
37167 | 1290 | 1330 | 1490 | 1870 | 2280 |
Each estimate reflects the 40th percentile of all rents, including utilities, in a ZIP code for a standard-quality home of the indicated size. In practical terms, a renter with a housing budget equal to a ZIP code’s small-area fair market rent for, let’s say, a two-bedroom rental home could expect to afford any one of around 40 percent of such rental homes available in the ZIP code. The other 60 percent of such rental homes in the ZIP code would be too expensive for the renter’s budget. HUD uses these estimates to determine the size of federal housing subsidies.
During the first part of this course, we will use small-area fair market rent estimates to learn how to wrangle, analyze, graph and map data using R and RStudio.
Below is the basic R script that extracted and displayed the data shown. You will modify and expand this basic script as we get into the more advanced procedures mentioned. Along the way, you will learn what every line of code you work with does.
For starters, though, try simply pasting the code into an R script window in RStudio and running it as is. If R produces the table of rent figures shown above, you’ll know you succeeded.
# Installing and loading required packages
if (!require("tidyverse"))
install.packages("tidyverse")
if (!require("gtExtras"))
install.packages("gtExtras")
library(tidyverse)
library(gtExtras)
library(readxl)
# Downloading data from:
# https://www.huduser.gov/portal/datasets/fmr/smallarea/index.html#year2024
download.file("https://www.huduser.gov/portal/datasets/fmr/fmr2024/fy2024_safmrs_revised.xlsx", "rent.xlsx", mode = "wb")
# Reading the downloaded Excel file into a data frame called FMR
FMR <- read_xlsx(path = "rent.xlsx", .name_repair = "universal")
# Making a list of Rutherford County ZIP codes
ZIPList <- c(
"37127",
"37128",
"37129",
"37130",
"37132",
"37085",
"37118",
"37149",
"37037",
"37153",
"37167",
"37086"
)
# Filtering for Rutherford ZIP codes and
# selecting columns of interest
FMR_RuCo <- FMR %>%
filter(ZIP.Code %in% ZIPList) %>%
select(ZIP.Code,
SAFMR.0BR,
SAFMR.1BR,
SAFMR.2BR,
SAFMR.3BR,
SAFMR.4BR) %>%
distinct()
# Renaming the columns
colnames(FMR_RuCo) <- c("ZIP",
"Studio",
"BR1",
"BR2",
"BR3",
"BR4")
# Showing the data as a table
FMR_RuCo_table <- gt(FMR_RuCo) %>%
tab_header("Rutherford FMR, by size and ZIP") %>%
cols_align(align = "left") %>%
gt_theme_538
FMR_RuCo_table
Follow the Small Area Fair Market Rent estimates link, and you may notice that the data are downloadable as an .xlsx file, the default format for the widely popular Microsoft Excel spreadsheet program. If you already know how to use Excel, you might reasonably question the value of learning an alternative to it, especially one that involves cryptic-looking computer code.
Excel is a handy, flexible, fast data analysis tool. I use it all the time. But working with data in R offers many advantages over working with data in a spreadsheet. To name three of the most important ones:
Capacity. Presently, an Excel worksheet can hold a little over a million horizontal rows and a little over 16,000 columns. That’s room enough for a pretty big dataset. But depending on what you are working with, it might not be enough. R’s capacity is limited only by the amound of RAM on your computer.
Functionality. In addition to doing basic data analysis, Excel can make nice-looking graphics. It even has rudimentary map-making abilities. At its core, though, Excel is accounting software. You can get Excel to do a wider range of things if you know how to create and use Excel macros. But macros are - guess what? - code. R can do much, much more than Excel can, especially if you factor in all the (free, by the way) add-on packages that people have developed for R.
Reproducibility. Excel generally can’t keep a record of all the pointing, clicking and manipulating you do while using it. As a result, it’s often difficult to show others how you got the results Excel gave you. Furthermore, there’s a good chance you’ll have to repeat all of that pointing, clicking and manipulating each time your raw data update or change. R offers advantages on both fronts. Anyone with a basic knowledge of R can look at the script shown above and understand exactly how the table of rent figures came about. Furthemore, changing just a few lines of code in the script could repeat the analysis for any other set of ZIP codes anywhere in the country, or for a later or earlier year.
Stick with R long enough to get past your anxiety about working with code, and I think you’ll end up preferring R over your favorite spreadsheet, at least for more complicated data tasks.