Skip to content

patmendoza330/redfinrentinc2021

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 

Repository files navigation

4/10/2022

Is it more expensive to rent or own?

This markdown will scrape the data within the Redfin article Rental Market Tracker: Rents Rise 14% in December—Biggest Jump in Over Two Years.

I’m going to pull in the table that they have in the article that shows average rent, mortgage, and associated annual increases.

article image

First things first - setting some variables

Set your working directory to wherever you’d like in the WORKINDIRECTORY section.

wd1 = WORKINGDIRECTORY
setwd(wd1)

Install and load any libraries

The tidyverse contains the rvest library which will be used to scrape the data, while dplyr and tidyr will be used to manipulate/transform data.

install.packages(c("tidyverse"))

Next, we want to load two libraries:

library(tidyverse)
library(rvest)

Although rvest is a component of the tidyverse, it doesn’t automatically load with the library call tidyverse, as a result, you’ll need to load it separately.

Scraping the table

redfin <- read_html('https://www.redfin.com/news/redfin-rental-report-december-2021/')

tablebucket <- redfin %>%
  html_element(xpath = '//*[@id="tablepress-306"]') %>%
  html_table()

Ok, so we’ve downloaded the table and have it in a tibble format. Lets go ahead and export it and load it into tableau.

write.csv(tablebucket, 'data/redfindata.csv', row.names = FALSE) 

Thats it!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published