The data we use is about Singapore Airbnb, the data include the information like location of different Airbnb in Singapore, the price of Airbnb and the room type. I face the challenge is overploting, there are a lot of Airbnb in Singapore, if we plot all of them on the map, there may be some overlapping on the map. It may confuse us on the distribution of the Airbnbs.
In order to solve challenge I faced, I use the alpha feature to set the alpha to 0.4 to increase the transparency level of the location points. Therefore, we can solve the overploting problem.
In order to plot the Airbnb to the map, we need to use some R related packages like tidyverse, ggplot2 and ggmap. We need to loading them in before start coding.
packages = c('tidyverse','ggplot2','ggmap')
for (p in packages){
if(!require(p, character.only = T)){
install.packages(p)
}
library(p,character.only = T)
}
The data is gotten from the kaggle website, named as " Singapore Airbnb" in the following website.: https://www.kaggle.com/jojoker/singapore-airbnb I name it as data and use read_csv function in tidyverse package to read it.
data <- read.csv("C:/Users/hp/Desktop/MITB/Vistual analytics/Assignment/Assignment 5/Air binBM/listings.csv")
In order to plot the Airbnb to Singapore map, we need to loading a background map first. We use get_map function in ggmap package to loading Singapore’s map. The first step of getting a map is to get a google map API.
ggmap::register_google(key = "AIzaSyC1KP3V6uEEhINSvlVMTo7sWNjphlxfz38")
map <- get_map("singapore", maptype = "roadmap", zoom = 11, source = "google")
## Source : https://maps.googleapis.com/maps/api/staticmap?center=singapore&zoom=11&size=640x640&scale=2&maptype=roadmap&language=en-EN&key=xxx
## Source : https://maps.googleapis.com/maps/api/geocode/json?address=singapore&key=xxx
ggmap(map)
We choose roadmap as maptype and choose zoom equals to 11 to show the full picture of Singapore.
We use ggmap to plot the overall situation of Singapore Airbnb. We set longitude and lattitude to x and y axis respectively. In aesthetics, we map room type to color and map price to size. We set alpha to 0.4 to overcome the overplotting problem.
ggmap(map)+
geom_point( data = data, aes(x=longitude,y=latitude,size=price,color=room_type),alpha=0.4)
After the seeing the overall picture of Singapore Airbnb, we can see the the Airbnb plotting in different neighborhood groups to see how the location difference will affect the price and room type of the Airbnb.
ggmap(map)+
geom_point( data = data, aes(x=longitude,y=latitude,color=room_type,size=price),
alpha = 0.2)+
facet_wrap(~neighbourhood_group)
Besides the neighborhood group, we can see the distribution of different room type.
ggmap(map)+
geom_point( data = data, aes(x=longitude,y=latitude,size=price),
alpha = 0.2)+
facet_wrap(~room_type)
Airbnb become a population choice for travelers to live in a new city. Singapore as a well-known travel city, there are a lot of Airbnb choices. This assignment plots all Singapore Airbnb to the map to figure out how the location affect the Airbnb in Singapore. From the overall plotting, we can see that there is a lot of Airbnb in Singapore and most of them distributed in the matured areas especially the central and south part of Singapore. No Airbnb at eastern part near Changi because there is an Airport and little Airbnb in the Boon Lay, Tuas and Jurong Island because there is industry park in Singapore and not popular for travelers. There is high density of Airbnb in central and south part of Singapore because there are a lot of famous insights like Merlion Park and Sentosa which are popular among the travelers. From the neighborhood group plotting, we can see that central region is the neighborhood group with the most Airbnb and north region is the neighborhood group with the least Airbnb. There are more Airbnb with high price located in central region compare to the other neighborhood group. North region has relatively less high-price Airbnb compare to other neighborhood groups. From the room type plotting, we can figure out that private room is the most common room type and share room is the least common room type, the number of shared room Airbnb is much lesser than the private room and entire room type Airbnb. Most of the entire home type of Airbnb is located on the south part of Singapore but private room type of Airbnb is distributed to the entire Singapore. The price of entire room is relatively higher than the private room and shared room. The shared room price is the lowest. Besides, there is the one Airbnb located in the west part of Singapore near Tuas, which is entire room type and high price. However it is the only one Airbnb located in that area which is far from the other Airbnbs.