---
title: "An Analysis on Airbnb Hosting in NYC 2019"
output:
flexdashboard::flex_dashboard:
theme: journal
social: menu
source_code: embed
---
```{r setup, include=FALSE}
library(flexdashboard)
library(dplyr)
library(tidyverse)
library(glue)
library(plotly)
library(ggpubr)
```
```{r}
airbnb <- read_csv("AB_NYC_2019.csv")
```
```{r}
NAexpelled1 <- airbnb%>%
mutate(last_review = replace_na(last_review, replace = mean(last_review, na.rm = T))) %>%
mutate(reviews_per_month = replace_na(reviews_per_month, replace = mean(reviews_per_month, na.rm = T)))
```
```{r}
airbnbclean <- NAexpelled1%>%
select(-id, -host_name, -host_id, -reviews_per_month, -calculated_host_listings_count, -last_review)
```
```{r}
data_airbnb <- airbnbclean %>%
mutate(potential_earnings = price * minimum_nights * availability_365)%>%
select(neighbourhood_group, potential_earnings) %>%
group_by(neighbourhood_group) %>%
summarise(max_potential_earnings = round(max(potential_earnings), 2))
```
```{r}
theme_algoritma <- theme(legend.key = element_rect(fill="black"),
legend.background = element_rect(color="white", fill="#263238"),
plot.subtitle = element_text(size=6, color="white"),
panel.background = element_rect(fill="#dddddd"),
panel.border = element_rect(fill=NA),
panel.grid.minor.x = element_blank(),
panel.grid.major.x = element_blank(),
panel.grid.major.y = element_line(color="darkgrey", linetype=2),
panel.grid.minor.y = element_blank(),
plot.background = element_rect(fill="#263238"),
text = element_text(color="white"),
axis.text = element_text(color="white")
)
```
```{r}
airbnbclean_vis <- airbnbclean %>%
group_by(neighbourhood_group, room_type) %>%
summarise(mean_price = round(mean(price),2)) %>%
ungroup()
```
```{r}
airbnb3 <- airbnbclean[ airbnbclean$number_of_reviews >= 150, ]
```
Column {data-width=550}
-----------------------------------------------------------------------
### Total Maximum Potential Earning of Airbnb Hosts in NYC
```{r}
Plot1_airbnb <- ggplot(data = data_airbnb, aes(x = reorder(neighbourhood_group,
max_potential_earnings),
y = max_potential_earnings,
text = glue("neighbourhood_group:{neighbourhood_group}
max_potential_earnings : {max_potential_earnings}")
)) +
geom_col(fill = "dodgerblue4") +
geom_col(data = filter(data_airbnb,
neighbourhood_group == "Manhattan"),
fill = "firebrick4") +
labs(x = NULL,
y = NULL,
title = "Total Max Potential Earning of Airbnb Hosts in NYC in the Year 2019") +
coord_flip() +
theme_algoritma
```
```{r}
plot1_inter_airbnb <- ggplotly(Plot1_airbnb, tooltip = "text")
plot1_inter_airbnb
```
Column {data-width=450}
-----------------------------------------------------------------------
### Average Price of Airbnb Room in NYC Year 2019
```{r}
options(scipen = 999)
airbnb_avg_pricerange <- ggplot(airbnbclean_vis, aes(x = reorder(neighbourhood_group,
mean_price),
y = mean_price,
text = glue("Type of Room: {room_type}
Mean Price: {mean_price}"))) +
geom_col(aes(fill = room_type), position = "dodge") +
labs(x = "Neighbourhood Group of NYC",
y = "Mean Price",
title = "Average Price of Airbnb Room in NYC Year 2019") +
theme(legend.position = "TRUE") +
theme_algoritma
```
```{r}
airbnb_avg_pricerange1 <- ggplotly(airbnb_avg_pricerange, tooltip = "text")
airbnb_avg_pricerange1
```
### Distribution of Review Received by Airbnb Hosts > 150
```{r}
airbnb_review <- ggplot(data = airbnb3, mapping = aes(x = neighbourhood_group,
y = number_of_reviews,
text = glue("Airbnb Host Name: {name}"))) +
geom_jitter(aes(color = neighbourhood_group)) +
scale_color_brewer(palette = "Set2") +
labs(x = "Neighbourhood Group",
y = "Total Review",
title = "Airbnb NYC Review Distribution Year 2019")+
theme(legend.position = "none")
```
```{r}
airbnb_review1 <- ggplotly(airbnb_review)
airbnb_review1
```