Take Home Exercise 2: Focusing on Airbnb and how their expansion has impacted our economy. Using Spatial Point Patterns Analysis of Airbnb Listing in Singapore.
Airbnb has expanded their services over 34,000 cities across 191 countries. However, Singapore is still one of the global cities that has yet to legalise short-term rentals offered by platforms such as Airbnb. Despite Singapore’s disregard of using Airbnb, there are still tools and datasets about Singapore that allows people to explore how Airbnb are used in the cities.
packages = c('maptools', 'sf', 'raster','spatstat', 'tmap', 'onemapsgapi', 'tidyverse', 'lubridate')
for (p in packages){
if(!require(p, character.only = T)){
install.packages(p)
}
library(p,character.only = T)
}
In this section, we need to investigate if the distribution of Airbnb listings are affected by location factors such as near to existing hotels, MRT services and tourist attractions.
Before we can analyse these points, we need to import and clean our data. Firstly, we import the Airbnb data using st_read() of sf package and transform the coordinate system to 3414.
airbnb <- read.csv("Airbnb_listing_30062019/30062019.csv")
We also want to extract the number and locations of hotels and tourist attractions in Singapore to see how this competition affects the Airbnb listings.
Extracting the data for MRT stations are also important for analysis. As the data for MRT station is in shp file format, we will use the following code to extract the data.
mrt <- st_read(dsn = "TrainStation",
layer = "MRTLRTStnPtt")
Reading layer `MRTLRTStnPtt' from data source
`D:\sarahcsp\IS415_blog\_posts\2021-09-14-take-home-exercise-2\TrainStation'
using driver `ESRI Shapefile'
Simple feature collection with 185 features and 3 fields
Geometry type: POINT
Dimension: XY
Bounding box: xmin: 6138.311 ymin: 27555.06 xmax: 45254.86 ymax: 47854.2
Projected CRS: SVY21
Since the MRT dataset is a shp file, it can be plotted immediately.
Since the Airbnb, hotels and tourists datasets that have been imported are in .csv format, we would need to convert them to sf for further analysis. Additionally, we need to change the coordinate system to 3414, the coordinate system of Singapore. As all of the data provided for latitude and longitude are in decimal degree format, we will assume that the data is in wgs84 Geographic Coordinate System.
Let’s plot to review the datasets that have been provided. This is the Airbnb map using airbnb_sf.
tmap_mode("view")
tm_shape(airbnb_sf) +
tm_dots(alpha = 0.4,
col = "blue",
size = 0.05) +
tm_basemap("OpenStreetMap")