The original datasets were all based on city and listing type (weekday or weekend). I needed to clean the data a bit and wrangle them into one main dataset. The parameter of interest was city.
Behind the scenes
library(tidyverse)library(ggplot2)library(dplyr)library(purrr)library(data.table)library(gsubfn)library(tidyr)library(flexdashboard)files <-dir(pattern ="*.csv")file.list <-sapply(files, read.csv, simplify=FALSE)airbnb <-rbindlist(file.list, idcol="city")[, city :=gsub("(.*)[_]([^.]+)[.].*", "\\1 \\2",city)]airbnb<-separate(airbnb, city, into =c("city", "type"), sep =" (?=[^ ]+$)")write.csv(airbnb, "airbnb.csv", row.names=FALSE)
Dashboard pieces
Next up was to subset the data based on city and create a color palette for the dashboard based on Airbnb brand colors. Then the various plots used in the dashboard were created.
Behind the scenes
airbnb_subset <- airbnb %>%filter(city == params$city)cbPalette <-c("#5AB2FF", "#00A699", "#FFE25A", "#845AFF", "#FC642D", "#FF5A5F")bedplot<-airbnb_subset %>%ggplot(aes(bedrooms, fill=type)) +geom_bar(stat="count",position="dodge")+theme_minimal()+theme(legend.position="bottom")+labs(fill="", x ="Number of Bedrooms", y ="") +scale_fill_manual(values=cbPalette)cleanplot<-airbnb_subset %>%ggplot(aes(cleanliness_rating, fill=room_type)) +geom_bar(stat="count",position="dodge")+theme_minimal()+theme(legend.position="bottom")+labs(fill="", x ="Cleanliness Rating", y ="") +scale_fill_manual(values=cbPalette)dist<-airbnb_subset %>%filter(realSum<4000) %>%ggplot(aes(x=metro_dist, y=realSum, color=type)) +geom_point(alpha=.5, size=2)+theme_minimal()+theme(legend.position="bottom")+labs(color="", x ="Distance from City Center", y ="Total Price") +scale_color_manual(values=cbPalette)
Dashboard layout
Finally the final layout was created to show the valueboxes and the plots that were layed out above.