airbnb <- read_csv(
"https://data.insideairbnb.com/united-states/ca/san-francisco/2026-06-14/data/listings.csv.gz"
) |>
mutate(price = parse_number(price))HW 02: EDA
Airbnb listings in San Francisco
Purpose
Airbnb has grown quickly in San Francisco, and its effect on the local housing market has become a real point of discussion. The website Inside Airbnb states that it is a “mission driven project that provides data and advocacy about Airbnb’s impact on residential communities.”
In this assignment we’ll explore a dataset of San Francisco Airbnb listings collected by Inside Airbnb to see how price and listing characteristics vary across room types.
- Practice translating a research question into a
dplyr/ggplot2pipeline - Choose an appropriate visualization for comparing a distribution across groups
- Use both a plot and summary statistics together to support a data-driven claim
Getting started
Load the tidyverse package. The data comes from Inside Airbnb as a compressed CSV file. You can learn more about the variables in the Inside Airbnb data dictionary.
Read in the San Francisco listings data. The price variable is stored with dollar signs and commas, so parse_number() converts it to a numeric variable that R can summarize and plot.
Get familiar with the data before diving into the exercises. Use functions like glimpse() or str() and review the Inside Airbnb data dictionary to learn what each variable means.
When you’re happy with your answers, commit and push your work to GitHub with a meaningful commit message.
Exercises
1. How many listings?
How many observations (rows) does the dataset have? Answer using inline code rather than hard-coding the number.
2. What does a row represent?
Based on the data documentation and after looking at the data, what does each row in the dataset represent?
3. Price distribution
3a. Initial plot
Create a histogram and a boxplot that show the distribution of Airbnb prices. What do you notice about the shape of the distribution? Are there any values that seem extreme?
3b. Zoom in
Adjust your plots above to control the x-limits to only show prices below 5000. Comment on this new view.
4. Summary statistics for price
Calculate the minimum, mean, median, standard deviation, IQR and maximum listing price. Interpret each number in context of the data set. Compare the mean and median - what does this tell you about the skew of the distribution? Based on this answer, which is the most appropriate measure of center? The mean or the median?
5. Filtered summary statistics for price
Apply a filter to the airbnb data to keep only listings with prices at or below $1000. Save this data set as a new object.
Recreate the summary statistics and at least one plot from Exercise 4. Which summary statistics changed the most? Which summary statistics changed the least?
6. Filtered price distribution by room type
Using only listings with prices at or below $1000, create a faceted histogram where each facet represents a room type (room_type) and displays the distribution of Airbnb prices (price) for that room type. Compare the frequency of responses and skew of prices across these different room types. Comment on one thing that you noticed.
7. Filtered summary statistics by room type
Using only listings with prices at or below $1000, calculate the minimum, mean, median, standard deviation, IQR, and maximum listing price for each room type. Use the visualization and the summary statistics together to describe the distribution of listing prices by room type. Point out any oddities in the numbers.
8. Review scores across room types
Create a visualization that helps you compare the distribution of review scores (review_scores_rating) across room types. Include a brief interpretation of how Airbnb guests rate properties in general and how room types compare to each other.
9. Is rating associated with price?
Create 2-3 scatterplots of price as the explanatory variable (on the x axis) against rating (as the response on the y axis). You could look at the pattern in the full data set, but likely to gain any meaningful information you will need to use a filtered data set (you can choose the dollar amount to filter on). You can color by a third variable if you choose to. Write 1-2 sentences about each plot sharing what you learned from that plot. Lastly try to answer the question “Do the highest reviewed places tend to be more expensive?”
10. What makes a good listing?
Revisit the data documentation and explore the relationship between some other measures that we have not looked at yet, and either the price, or the rating of a listing. Create at least 2-3 graphs to explore your chosen relationship, calculate appropriate summary statistics and summarize what you’ve learned.
Submission Process
- This repo has been distributed to you in our class organization
- Clone this repo to your RStudio in JupyterHub
- Do the work. Render often (probably after each question), commit at least 3 times in the process.
- Do one final render to PDF, commit and push with the message “Done with HW02”
- Export your PDF out of R Studio, and Submit to Gradescope via Canvas.
Grading Rubric
TBD, but at least 1 point will be based on your commit history.
This page adapts Data Science in a Box (HW 02: “Airbnb listings in Edinburgh”) by Mine Çetinkaya-Rundel, licensed under CC BY-SA 4.0. Source: tidyverse/datascience-box. Modifications include github language, changing datasets & specific questions.