library("flexdashboard")
library(tidyverse)
library(plotly)
library(janitor)
library("sqldf")
library("stringr")
# Load data here
hotel_reviews <- read_csv("/Users/thuyvu/Desktop/cleaned_hotel_review.csv") %>%
janitor::clean_names() %>%
mutate(reviewer_nationality = ifelse(is.na(reviewer_nationality), "UNKNOWN", reviewer_nationality))
hotel_reviews$country_of_hotel <- ifelse(word(hotel_reviews$hotel_address, -1) == "KINGDOM", coalesce(word(hotel_reviews$hotel_address, -2, -1), word(hotel_reviews$hotel_address, -1, -1)), word(hotel_reviews$hotel_address, -1))
Do the following:
geom_point()).top_5_hotel_in_uk <- sqldf("select distinct hotel_name, average_score from hotel_reviews where country_of_hotel == 'UNITED KINGDOM' group by hotel_name order by average_score desc limit 5") %>%
mutate(hotel_name = case_when(hotel_name == "THE SOHO HOTEL" ~ "THE SOHO", hotel_name == "TAJ 51 BUCKINGHAM GATE SUITES AND RESIDENCES" ~ "BUCKINGHAM", hotel_name == "MILESTONE HOTEL KENSINGTON" ~ "MILESTONE", hotel_name == "HAYMARKET HOTEL" ~ "HAYMARKET", hotel_name == "41" ~ "41"))
figure_4 <- ggplot(top_5_hotel_in_uk) +
aes(x = hotel_name, y = factor(average_score), fill = hotel_name) +
geom_col(aes(x=reorder(hotel_name, -average_score))) +
theme_minimal() + scale_fill_brewer(palette = "Set2") + labs(title="TOP 5 HOTELS IN THE UK", x = "HOTEL NAME", y = "SCORE", fill = "HOTEL NAME")
figure_4
ggsave("figure_4.png", width = 20, height = 20, units = "cm", path = "/Users/thuyvu/Desktop/data")
ggplotly().ggplotly(figure_4)
Good luck and have fun!