-
Notifications
You must be signed in to change notification settings - Fork 3
/
rhousehunter-vignette.Rmd
74 lines (52 loc) · 3.14 KB
/
rhousehunter-vignette.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
---
title: "Rhousehunter Vignette"
output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{rhousehunter-vignette}
%\VignetteEngine{knitr::knitr}
%\VignetteEncoding{UTF-8}
%\usepackage[UTF-8]{inputenc}
---
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>"
)
```
```{r setup}
library(rhousehunter)
```
House hunting can be a daunting experience given there is so much information to consider. `rhousehunter` aims to simplify the information collection process for end-users with four simple function syntax in R.
This document will show you how to use the functions of `rhousehunter` package to gather rental information on Craiglist with ease.
#### Scraping
The first function in our package is the `scraper()`. Here you will input a Craigslist housing url for the main housing and apartment rentals page of Craigslist BC and designate the argument `online = TRUE` to scrape directly from the internet. When `online = FALSE` the scraper function will scrape from a local HTML file, this may be handy if the Craigslist website is down or for internal development and test. Please note that you cannot input the url for an individual listing.
```{r Scraper function}
url <- "https://vancouver.craigslist.org/d/apartments-housing-for-rent/search/apa"
scraped_data <- scraper(url, online = FALSE)
head(scraped_data)
```
#### Cleaning
Our `data_cleaner()` function is straightforward and powerful tool. It turns the tibble with data generated by the `scraper()` function into a clean and tidy tibble object. It has a single input, which is the output of the `scraper()` function.
```{r Cleaner function}
cleaned_data <- data_cleaner(scraped_data)
head(cleaned_data)
```
#### Filtering
The `filter()` function allows you to filter the cleaned data to find the rentals meeting your specifications. The inputs of this function include: the tibble object generated by `data_cleaner()`, along with the numeric values for the minimum price, maximum price, minimum square feet, minimum number of bedrooms, and a string of the city name of the desired rentals. It outputs a tibble object with the matching results.
```{r Filter Function}
filtered_data <- data_filter(cleaned_data,
min_price = 1000,
max_price = 2000,
sqrt_ft = 500,
num_bedroom_input = 1,
city_input = 'Vancouver')
filtered_data
```
#### Emailing
At this stage, you can choose to email your filtered results in a `.csv`. You will need to input the email address you wish to send the results to and the filtered tibble object. You also have the choice to change the optional `email_subject` argument to set your email subject. After the function runs through smoothly without error, you should also receive an email from pyhousehunter@gmail.com in your chosen email's inbox.
```{r Send Email function, message=TRUE}
send_email(email_recipient = "elabandari@gmail.com",
filtered_data = filtered_data,
email_subject = 'Results from RHouseHunter')
```
We do hope `rhousehunter` makes your house hunting process easier.