Project

Author

Liliia Gileva

Logo

1 Hotel Bookings Analysis

2 Introduction

This report will be focused on analysing the hotel bookings dataset. It contains data on the year the booking was made, gender, age and country of origin of the person booking, destination country, hotel name, hotel rating, payment method, number of guests, number of days, number of rooms, price and discount provided.

The main topics that will be covered:

  1. Customers Profiling.
  2. Countries of Destination.
  3. Pricing and Payment Methods.
  4. Change in Customers booking behaviour over the years of 2010 and 2019.
  5. Best Performing Hotels.
library(tidyverse)
library(grid)
library(gridExtra)
library(kableExtra)
hotel_bookings <- read_csv("hotel_bookings.csv")

2.1 Customers Profiling

Firstly, we will view the customer profile, their gender and age distribution.

hotel_bookings <- mutate(hotel_bookings, age = case_when(
                                                  age < 20 ~ "below 20",
                                                  age < 30 ~ "20-30",
                                                  age < 40 ~ "30-40",
                                                  age < 50 ~ "40-50",
                                                  age < 60 ~ "50-60", 
                                                  TRUE ~ "above 60")) 



sorted_age <- hotel_bookings %>%
  arrange(age)

ggplot(sorted_age, aes(x = age)) + 
  geom_histogram (stat = "count", binwidth = 15, fill = "royalblue1") + 
  ggtitle("Age Distribution") + 
  xlab("Age Brackets") +
  ylab("# of Bookings")

# using case_when function to devide ages into groups for easier understanding
# stat = "count" used here to calculate the number of occurrences for each group like "above 60"

The age distribution of customers booking is quite wide. People who booked the hotel vary in ages from 20 to 60 with no particular group that would book more often.

ggplot(hotel_bookings, aes(x=gender)) + 
  geom_bar(width = 0.5, fill = c("royalblue1", "royalblue4")) + 
  ggtitle("Gender Split") + 
  ylab("# of Bookings") +
  xlab("Gender") + 
  geom_text(stat = "count", aes(label = ..count.. ), color = "white", size = 4.5, vjust = 5, hjust = 0.5) + 
        theme_classic()

# stat = "count" here annotates the bars with the count number and aes(label = ..count..) specifies that the annotation should be the count

The gender split is equal showing us that both men and women are making bookings.

The next graph analyses the countries from which bookings were made. As we can see from the bar chart the most bookings were made from Thailand, with similarly large number from Malasyia, Singapore and Indonesia.

origin_country_count <- hotel_bookings %>%
  group_by(origin_country = origin_country) %>%
  summarize(count = n()) 

origin_country_count <- origin_country_count %>%
  mutate(origin_country = fct_reorder(origin_country, count))

ggplot(origin_country_count, aes(y = origin_country, x = count, fill = count)) + 
  geom_bar(stat = "identity", width = 0.5) + 
  ggtitle("Number of Bookings by Country of Origin") +
  xlab("# of Bookings") +
  ylab("Country of Origin") +
  scale_fill_gradient(low = "lightblue1", high = "royalblue2") +
  theme_minimal() + 
  theme(legend.position = "none") 

# legend.position = "none" is used to remove the irrelevant legend from the graph

2.2 Countries of Destination

In this section we will look at where people travel the most and how many days they spend in each country on average.

Looking at the destinations, the highest number of booking was made in New Zealand with 3447 bookings, Nepal follows closely with 3446 and Egypt in third with 3422 bookings, showing that the top three are tightly grouped.

destination_country_count <- hotel_bookings %>%
  group_by(destination_country = destination_country) %>%
  summarize(count = n())

destination_country_count <- destination_country_count %>%
  mutate(destination_country = fct_reorder(destination_country, count))

ggplot(destination_country_count, aes(y = destination_country, x = count, fill = count)) + 
  geom_bar(stat = "identity", width = 0.5) + 
  ggtitle("Number of Bookings by Country of Origin") +
  xlab("# of Bookings") +
  ylab("Country of Origin") +
  geom_text(aes(label = count), color = "white", size = 2.5, hjust = 1.5) +
  scale_fill_gradient(low = "steelblue1", high = "royalblue4") +
  theme_minimal() + 
  theme(legend.position = "none") 

# stat = "identity" is used to take values directly from the data without any transformations as they were done before when the new data was created and counted for this analysis 

The table below represents how many days people spend on average in each country.

avg_days_spend_by_country <- hotel_bookings %>%
  group_by(destination_country) %>%
  summarise(num_days = mean(num_days)) %>%
  arrange(desc(num_days))

  knitr::kable(avg_days_spend_by_country,
  digits = c(0,2), 
  align = "lr", 
  col.names = c("Destination Country", "Average Number of Days spent"),
  caption = "Average number of days spent by Destination Country", table.attr = 'data-quarto-disable-processing = "true"') %>%
    kable_styling(full_width = FALSE) %>%
    row_spec(0, bold = TRUE, color = "white", background = "darkblue") %>%
    column_spec(1, bold = TRUE, color = "darkblue") %>%
    column_spec(2, italic = TRUE)
Average number of days spent by Destination Country
Destination Country Average Number of Days spent
Brazil 3.37
India 3.33
Italy 3.31
Canada 3.28
Colombia 3.28
Mexico 3.27
China 3.26
Denmark 3.26
Egypt 3.25
Ireland 3.24
Nepal 3.23
Japan 3.22
France 3.22
Germany 3.21
New Zealand 3.17
Israel 3.17
Iran 3.17
Iceland 3.16
Kenya 3.15
Maldives 3.11

The number of days spend in each destination country does not vary widely. On average people spent 3 days no matter of the destination. When looking more in depth, Brazil was the country were people would spend more time along with Canada and India. Maldives and Kenya have the shortest period of stay.

For the next analysis we need to calculate average price per night to find out what countries are the most and least expensive to stay in.

As for average booking price in each of the countries, we can see that the most expensive would be a night in Iceland at 131 euros and Germany at 130 euros. the least expensive would be Mexico and India with the prices per night around 123 euros.

hotel_bookings <- mutate(hotel_bookings, price_per_night = booking_price/num_days)

avg_price_per_country <- hotel_bookings %>% 
  group_by(destination_country) %>%
  summarise(average_price_per_night = mean(price_per_night))%>%
  arrange(desc(average_price_per_night))

avg_price_per_country$average_price_per_night <- round(avg_price_per_country$average_price_per_night, 0)

avg_price_per_country <- avg_price_per_country %>%
  mutate(destination_country = fct_reorder(destination_country,average_price_per_night))

ggplot(avg_price_per_country, aes(y = destination_country, x = average_price_per_night, fill = average_price_per_night)) +
  geom_bar(stat = "identity") + 
        ggtitle("Average price per night by Country") + 
        xlab("Average price per night") +
        ylab("Destination Country") + 
        geom_text(aes(label = paste0("€", average_price_per_night)), 
        hjust = 1.5, size = 3, color = "white") +
        scale_fill_gradient(low = "steelblue1", high = "royalblue4") +
        theme_minimal() +
        theme(legend.position = "none")

# $ is used to target specific column in the data to change it
# paste0 is used to combine the text you want to put in with values

2.3 Pricing and Payment methods

Now let’s make a profile of the pricing and how much people were willing to spend on the hotels based on how many rooms they booked.

ggplot(hotel_bookings, aes(x = num_rooms, y = price_per_night, fill = cut(num_rooms, breaks = 4))) + 
        geom_boxplot(outlier.shape = 17, outlier.colour = "darkblue") +
        ggtitle("Price per Night Distribution") + 
        xlab("Number of Rooms") +
        ylab("Price per night") + 
        scale_fill_manual(values = c("lightblue1","steelblue1", "royalblue1", "royalblue4")) +
        theme_classic() +
        theme(legend.position="none")

# cut function is used to set the color for each on the box plots in the following function scale_fill_manual

The boxplot illustrates that most of the people spent around 60-70 euros regardless of how many rooms booked. But we can see that some people, booking 1 or 2 rooms, tend to go for more expensive rooms (see outliers).

Regarding payment method used when booking, we have people paying with Wallet, Credit card, COD, Internet Banking and Debit Card.

average_discount <- hotel_bookings %>%
  group_by(payment_method) %>%
  summarise(average_discount = mean(discount_pct))

average_discount$average_discount <- round(average_discount$average_discount, 2)

average_discount$payment_method <- factor(average_discount$payment_method, levels = unique(average_discount$payment_method[order(average_discount$average_discount)]))

ggplot(average_discount, aes(x = payment_method, y = average_discount, fill = payment_method)) +
  geom_bar(stat = "identity") +
  geom_text(aes(label = paste0(average_discount, "%")), 
            vjust = -0.5, size = 3) +
  labs(title = "Discounts by Payment Method",
       x = "Payment Method",
       y = " Average Discount (%)") +
      scale_fill_manual(values = c("lightblue1","steelblue1", "steelblue2", "royalblue1", "royalblue4")) +
  theme_minimal()

As we can see on the barchart, there is no particular preferred method for paying, however people tend to pay using wallet slighly more.

Regarding the relationship between booking price and discount percentage, we thought there may be some connection for example you may be more likely to book a more expensive room if it had a higher disscount, however there is no such relationship visible.

ggplot(hotel_bookings, aes(y = booking_price, x = discount_pct)) + 
        geom_point(width = 0.5, color = "darkblue") + 
        ggtitle("Booking price and Discount Relationship") + 
        xlab("Discount Percentage") +
        ylab("Booking Price") + 
        theme_minimal()

2.4 Change in Customers booking behavior over the years of 2010 and 2019

Firstly, we can see that the number of booking made was growing with the time. In 2010 the number of bookings was close to 5,000, whenever in 2019 it grew up to 9501 bookings.

bookings_by_year <- hotel_bookings %>%
  group_by(year = year) %>%
  summarize(bookings_count = n())

ggplot(bookings_by_year, aes(x = year, y = bookings_count, color = bookings_count)) +
  geom_line() +
  geom_point(size = 3) + 
  labs(title = "# of bookings made by Year", x = "Year", y = "# of Bookings") +
  geom_text(aes(label = bookings_count), vjust = -1, hjust = 0.5, color = "royalblue4") +
  scale_color_gradient(low = "lightblue2", high = "royalblue4") + 
  scale_x_continuous(breaks = unique(bookings_by_year$year)) +
  theme_minimal() +
  theme(legend.position = "none") +
  coord_cartesian(ylim = c(0, 11000)) 

# coord_cartesian(ylim) is used to make the field for the grapgh wider
# scale_x_continious is used to show each of the years as they are shown in dataset without R transforming them 

Moving to the next graph, average night price per night was fluctuating over the years as well. It can be seen on the line graph that there was a drop to 70 euros per night in 2014, after the most expensive year of 2013 when the price per night was 167 euros. After the big drop it started to grow again and reached 160 in 2018.

avg_price_per_night <- hotel_bookings %>%
  group_by(year) %>%
  summarise(price_per_night = mean(price_per_night))

avg_price_per_night$price_per_night <- round(avg_price_per_night$price_per_night, 0)

ggplot(avg_price_per_night, aes(x = year, y = price_per_night, color = price_per_night)) +
  geom_line() +
  labs(title = "Average Nights Spent per Year",
       x = "Year",
       y = "Average Spend per Night") +
  geom_text(aes(label = paste0("€",price_per_night)), 
            vjust = -0.5, hjust = 1.3, size = 3, color = "royalblue4") +
  geom_point(size = 3) +
  scale_x_continuous(breaks = unique(hotel_bookings$year)) +
  scale_fill_gradient(low = "lightblue1", high = "royalblue4") +
  theme_minimal() +
  theme(legend.position="none")

2.5 Best Performing Hotels

The table below shows the most popular hotels by destination and how many times people visited them over the given periof of time. Also it shows the average price of the booking per night. The most recurring hotel there is Grand Hayaat which seems to be a popular chain hotel with people from different countries. The profit the most popular hotels received varies from 2,718 euros to 4,250 euros over all years.

hotel_popularity <- hotel_bookings %>%
  group_by(destination_country, hotel) %>%
  summarize(popularity = n(), sum_price = sum(booking_price))

popular_hotels <- hotel_popularity %>%
  group_by(destination_country) %>%
  arrange(desc(sum_price)) %>%
  slice(1)
  
knitr::kable(popular_hotels,
  align = "llrr",
  digits = c(0,0,0,2),
  col.names = c("Destination Country", "Most Popular Hotel", "# of Visits", "Profit in €"),
  caption = "Most Popular Hotels by Destination", 
  table.attr = 'data-quarto-disable-processing = "true"') %>% 
  kable_styling(full_width = FALSE) %>%
    row_spec(0, bold = TRUE, color = "white", background = "darkblue") %>%
    column_spec(1, bold = TRUE, color = "darkblue") %>%
    column_spec(2, italic = TRUE) %>%
  column_spec(4, italic = TRUE)
Most Popular Hotels by Destination
Destination Country Most Popular Hotel # of Visits Profit in €
Brazil Element 15 4249
Canada Ace Hotel 17 3500
China Park Central Hotel 14 2899
Colombia The Keating Hotel 16 3710
Denmark Grand Hyatt 17 3517
Egypt Hotel Lemonade 17 3793
France Cordial Hosts 13 3607
Germany Hotel Vitale 12 3160
Iceland Denali Perch Resort 12 3444
India Isle Royale 12 3365
Iran Brewery Gulch Inn 13 3225
Ireland Grand Hyatt 13 3006
Israel The Orchard Hotel 11 3073
Italy The Palazzo 14 3153
Japan Bluebird Guesthouse 14 2965
Kenya Bourbon Bliss 12 3638
Maldives Grand Hyatt 19 3289
Mexico Able Day Hotel 10 2718
Nepal The Resting Place 13 3082
New Zealand Coastline Bay Hotel 12 3366
# slice (1) is used to get the output of the first row 

3 Conclusion

To sum up the analysis of hotel booking data, the following points were made:

  • The target market is equal male/female split, aged from 20 to 50 mostly from Thailand, Malasyia or Singapore
  • People are mostly travelling to New Zealand, Nepal or Egypt and spend there around 3 days.
  • Based on average price per night for each of countries and most visited countries, it can be said that customers are not price sensitive.
  • Over the years the number of bookings was growing and and the average price per night was going up and dropping, staying relatively high in 2019 at 133 euros.
  • The most popular hotel over all countries is Grand Hyatt making profit in the shown destinations over 3,000 euros.

Meme