We look at the private property market of Singapore from Realist. However, for new property launches, the price is dictated by the developer. In this study, we will study the price changes of the property based on the number of sale and time.
Sketch
By allowing users to select the projects in order to see only the interested results. It will also allow users to compare projects.
packages <- c("tidyverse","reshape2", "ggpubr", "plotly", "crosstalk")
for (p in packages){
if(!require(p, character.only = T)){
install.packages(p)
}
library(p, character.only = T)
}
list2018 <- read_csv("Data/realis2018.csv")
list2019 <- read_csv("Data/realis2019.csv")
realist <- rbind(list2018,list2019)
Since the “Sale Date” is given as a string, conversion to the date is required. We then extract only the Month and Year from the date.
realist$`Sale Date` <- as.Date(realist$`Sale Date`, "%d-%b-%y")
realist$MonthYear <- format(as.Date(realist$`Sale Date`), "%Y-%m")
Remove all with less than 100 transactions of New Sale. Then, aggregate the data by Project Name and Month-Year. Create values for their average monthly price and number of monthly transactions.
realist_clean <- realist %>%
group_by(`Project Name`) %>%
filter(n() >= 100 & `Type of Sale` == "New Sale")
realist_clean <- realist_clean %>%
group_by(`Project Name`, MonthYear) %>%
summarise(mean(`Unit Price ($ psf)`), n())
colnames(realist_clean) <- c("Project", "Time", "Price", "Count")
Create 2 plots, a line graph showing the price variation through time and 1 histogram to show the number of sales. Using a filter to allow selection of each of the project will allow users to visualize the price and sale volume.
shared <- realist_clean %>%
SharedData$new(key = ~Project)
p1 <- shared %>%
plot_ly(x = ~Time, y = ~Price, color = ~Project) %>%
group_by(Project) %>%
add_lines() %>%
hide_legend()
p2 <- shared %>%
plot_ly(x = ~Time, y = ~Count, color = ~Project) %>%
group_by(Project) %>%
add_bars() %>%
hide_legend()
bscols(list(filter_select(id = "Name", label = "Select a Project", sharedData = shared, group = ~Project), bscols(p1, p2)))
Due to the large numbers of projects involved, it will result in overplotting. By allowing selection, we will only display data that are relevant.
With “hoverinfo”, we will be able to tell the exact value when we hover over the interested data. This will not be possible with static charts where we can only get an estimate as good as the gridlines’ precision.
By using the “SharedData” functiom, we are able to link the charts. This allow users to see all relavent information across all linked charts.