September 6, 2019

1. Overview

The Berlin_Listings App features all Airbnb listings for the city of Berlin in Germany, and allows the user to filter the original database, by selecting neighbourhood groups, room types, a price range and an availability range.

  • The user can visualize the information via a leaflet-generated map.
  • A particular listing can be selected in the map and display aditional information by clicking on its marker
  • The aditional information to be displayed on a particular marker popup: Listing Name, Listing ID, Neighbourhood, Host, Room type, and Price.
  • A price summary is included for the selected listings.

The Berlin_Listings app can be foud here

2. Data

  • The original dataset was scraped on November 07th, 2018 and contains detailed listings data of current Airbnb listings in Berlin.
  • This data was created by Murray Cox and his Inside Airbnb project which can be found here.
  • Data overview:
## 'data.frame':    22552 obs. of  16 variables:
##  $ id                            : int  2015 2695 3176 3309 7071 9991 14325 16401 16644 17409 ...
##  $ name                          : Factor w/ 21874 levels "","'attic with a view'",..: 3411 15624 9734 3867 5313 10763 1957 2033 12067 9430 ...
##  $ host_id                       : int  2217 2986 3718 4108 17391 33852 55531 59666 64696 67590 ...
##  $ host_name                     : Factor w/ 5998 levels "","'Tom","(Email hidden by Airbnb)",..: 2304 3903 859 2521 850 4519 1046 3859 4699 5811 ...
##  $ neighbourhood_group           : Factor w/ 12 levels "Charlottenburg-Wilm.",..: 5 7 7 11 7 7 7 2 2 7 ...
##  $ neighbourhood                 : Factor w/ 136 levels "Adlershof","Albrechtstr.",..: 19 97 100 109 50 100 97 33 77 100 ...
##  $ latitude                      : num  52.5 52.5 52.5 52.5 52.5 ...
##  $ longitude                     : num  13.4 13.4 13.4 13.3 13.4 ...
##  $ room_type                     : Factor w/ 3 levels "Entire home/apt",..: 1 2 1 2 2 1 1 2 1 2 ...
##  $ price                         : int  60 17 90 26 42 180 70 120 90 45 ...
##  $ minimum_nights                : int  4 2 62 5 2 6 90 30 60 3 ...
##  $ number_of_reviews             : int  118 6 143 25 197 6 23 0 48 279 ...
##  $ last_review                   : Factor w/ 1313 levels "","2010-09-16",..: 1303 1276 724 1230 1310 1206 1307 1 986 1306 ...
##  $ reviews_per_month             : num  3.76 1.42 1.25 0.39 1.75 0.15 0.23 NA 0.47 2.83 ...
##  $ calculated_host_listings_count: int  4 1 1 1 1 1 3 1 2 1 ...
##  $ availability_365              : int  141 0 220 297 26 137 129 365 159 42 ...

3. App Contents

  • This app has several input and output components, as well as ui elements to help visualize the information and documentation.

4. Example: A summary

An example of an operation performed by the app is the price summary (here performed on the entire dataset).

summary(listings$price)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    0.00   30.00   45.00   67.14   70.00 9000.00

5. Code example

The code example for the server.R file:

library(shiny)
library(dplyr)
# Define server logic 
shinyServer(function(input, output) {
        lstDa <- reactive({
                filter(listings, 
                       price>=input$priceSlider[1],
                       price<= input$priceSlider[2],
                       neighbourhood_group %in% input$location,
                       room_type %in% input$roomType,
                       availability_365>= input$availabilitySlider[1],
                       availability_365 <= input$availabilitySlider[2]
                )
        })
                
        output$map1 <- renderLeaflet({
                listdata <- lstDa()
                leaflet(listdata ) %>%
                        addTiles() %>%
                        addMarkers(popup = paste0(
                                "<br/>Name: ", "<strong>",(listdata$name),"</strong>",
                                "<br/>id: ", listdata$id,
                                "<br/>Neighbourhood: ", listdata$neighbourhood,
                                "<br/>Host: ", listdata$host_name,
                                "<br/>Room Type: ", listdata$room_type,
                                "<br/>Price: ", "$",format(listdata$price, big.mark = ",", nsmall = 2, decimal.mark = ".")
                                ),
                                label = listdata$name,
                                clusterOptions = markerClusterOptions(),
                                lng = listdata$lng, lat = listdata$lat
                                )
        })
        output$priceTable <- renderPrint({
                listdata <- lstDa()
                summary(listdata$price)
        })
})
  • The code for both the ui.R and the global.R file can be found at the GitHub repo for this app.