library(readxl)
library(dplyr)
library(ggplot2)
# Read the Airbnb dataset (this file opens as an Excel workbook).
df <- read_excel("Airbnb_DC_25.csv")
# Find the median price for each room type.
price_by_room <- df %>%
filter(!is.na(price), price > 0, room_type %in% c("Entire home/apt", "Private room", "Hotel room")) %>%
group_by(room_type) %>%
summarize(median_price = median(price), listings = n(), .groups = "drop")
# Make a bar chart to compare the prices.
ggplot(price_by_room, aes(x = room_type, y = median_price, fill = room_type)) +
geom_col(width = 0.65) +
geom_text(aes(label = paste0("$", round(median_price))), vjust = -0.4, size = 4) +
scale_fill_manual(values = c("Entire home/apt" = "#3478B7", "Private room" = "#E69F00", "Hotel room" = "#53A58A"), name = "Room type") +
scale_y_continuous(limits = c(0, 340), expand = expansion(mult = c(0, 0))) +
labs(title = "Typical Airbnb Nightly Price by Room Type in Washington, DC",
x = "Room Type", y = "Median Nightly Price (USD)",
caption = "Source: Airbnb_DC_25.csv (course dataset); listings with available positive prices") +
theme_minimal(base_size = 12) +
theme(axis.text.x = element_text(angle = 12, hjust = 1), legend.position = "right")Airbnb DC Homework Assignment
Description and Key Insight
I wanted to see how much Airbnb prices change depending on the type of room you book in Washington, DC, so I made a bar chart comparing three room types. I used different colors to make the chart easier to read and looked at the median price instead of the average, since some listings can be really expensive. What surprised me was that hotel rooms had the highest median price at $292 per night, while entire homes or apartments were $146. Private rooms were the cheapest at $68, which makes them a good option for people trying to save money on their stay.