Use the homer package with R to collect and analyze publicly available residential real estate data. The plot below represents daily home values over the course of a couple months for a home I just sold. Actually, the buying and selling of my home was the inspiration for this package. I wanted to make sure I had the best available information for decision making. 314 Wood Hollow was listed for sale in early October and a sale was final on December 15.

library("homer")
library("ggplot2")
library("xml2")
library("glue")
library("lubridate")
library("stringr")

ts <- paste0(
    year(Sys.Date())
    , str_sub(paste0("0", month(Sys.Date())), -2)
    , str_sub(paste0("0", day(Sys.Date())), -2))
zillow_dir <- system.file(package = "homer", "extdata")
homer::plot_zillow_directory(zillow_dir, strip_font_size = 12, nudge_y = 800, value_size = 2.6)

Step 1. Obtain Zillow API Key

Follow the instructions to Get Started with the Zillow API and obtain an API key. Save the key your .Renviron startup file.

# Open the .Renviron file.
file.edit("~/.Renviron")
# Add the following line:
ZILLOWAPI="[Your API key here]"

# Save the file.

Step 2. Gather Data

Find the Zillow-ID for a property for which you wish to pull information. The Zillow-ID for the 314 Wood Hollow property is 36086728.

l <- home_estimate("36086728", format = "list")

The Zillow API returns a lot of information. Try something like this to pull the estimated property value.

# Current value of the property
l$zestimate$response$zestimate$amount[[1]]
str(l)

Try exploring the rest of list with on your own. The structure (str) of the list is available in the Appendix.

Step 3. Archive the data

Switch the format of the data returned from the Zillow API to "xml," a more suitable format for archiving the data. Then use R functions from the xml2 package to save to an archive directory.

x <- home_estimate("36086728", format = "xml")
write_xml(x, glue('{zillow_dir}/36086728-{ts}.xml'))

HINT: Set up a Scheduled Task to automate this simple operation on a recurring basis.

Step 4. Plot accumulated data

After you have some data accumulated over time for a single property, you will be ready to plot the information. Here is a starter function. Feel free to modify to suit your needs.

homer::plot_zillow_directory(zillow_dir, strip_font_size = 12, nudge_y = 800, value_size = 2.6)

Multiple Properties in the archive directory are treated as "facets" on the plot without any additional code.

Appendix




billzichos/homer documentation built on May 12, 2019, 12:23 a.m.