Assignment 5

Assignment 5

library(tidyverse)
── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr     1.2.1     ✔ readr     2.2.0
✔ forcats   1.0.1     ✔ stringr   1.6.0
✔ ggplot2   4.0.3     ✔ tibble    3.3.1
✔ lubridate 1.9.5     ✔ tidyr     1.3.2
✔ purrr     1.2.2     
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag()    masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
df <- read_csv("airbnb_ny19.csv")
Rows: 48895 Columns: 16
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr  (6): name, host_name, neighbourhood_group, neighbourhood, room_type, la...
dbl (10): id, host_id, latitude, longitude, price, minimum_nights, number_of...

ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
df
# A tibble: 48,895 × 16
      id name       host_id host_name neighbourhood_group neighbourhood latitude
   <dbl> <chr>        <dbl> <chr>     <chr>               <chr>            <dbl>
 1  2539 Clean & q…    2787 John      Brooklyn            Kensington        40.6
 2  2595 Skylit Mi…    2845 Jennifer  Manhattan           Midtown           40.8
 3  3647 THE VILLA…    4632 Elisabeth Manhattan           Harlem            40.8
 4  3831 Cozy Enti…    4869 LisaRoxa… Brooklyn            Clinton Hill      40.7
 5  5022 Entire Ap…    7192 Laura     Manhattan           East Harlem       40.8
 6  5099 Large Coz…    7322 Chris     Manhattan           Murray Hill       40.7
 7  5121 BlissArts…    7356 Garon     Brooklyn            Bedford-Stuy…     40.7
 8  5178 Large Fur…    8967 Shunichi  Manhattan           Hell's Kitch…     40.8
 9  5203 Cozy Clea…    7490 MaryEllen Manhattan           Upper West S…     40.8
10  5238 Cute & Co…    7549 Ben       Manhattan           Chinatown         40.7
# ℹ 48,885 more rows
# ℹ 9 more variables: longitude <dbl>, room_type <chr>, price <dbl>,
#   minimum_nights <dbl>, number_of_reviews <dbl>, last_review <chr>,
#   reviews_per_month <dbl>, calculated_host_listings_count <dbl>,
#   availability_365 <dbl>
by_neighborhood_group <- df |> 
  group_by(neighbourhood_group) |> 
  summarize(count = n(),
            avg_price = mean(price),
            avg_listings = mean(calculated_host_listings_count),
            avg_avail = mean(availability_365))

by_neighborhood_group
# A tibble: 5 × 5
  neighbourhood_group count avg_price avg_listings avg_avail
  <chr>               <int>     <dbl>        <dbl>     <dbl>
1 Bronx                1091      87.5         2.23      166.
2 Brooklyn            20104     124.          2.28      100.
3 Manhattan           21661     197.         12.8       112.
4 Queens               5666      99.5         4.06      144.
5 Staten Island         373     115.          2.32      200.
library(viridis)
Loading required package: viridisLite
library(pheatmap)
by_neighborhood_group_matrix <- data.matrix(by_neighborhood_group[, -1])
row.names(by_neighborhood_group_matrix) <- by_neighborhood_group$neighbourhood_group
neighborhood_heatmap <- pheatmap(by_neighborhood_group_matrix,
                                 cluster_rows = FALSE,
                                 cluster_cols = FALSE,
                                 scale = "column",
                                 display_numbers = round(by_neighborhood_group_matrix, 1),
                                 number_color = "white",
                                 color = viridis(25),
                                 legend = FALSE,
                                 angle_col = 0,
                                 main = "Heatmap of New York Neighborhood AirBnB Statistics")

Data from AirBnB via https://drive.google.com/drive/folders/1AMRfddeMwKRaNidOV87JP1iCVn_z-Uv_

Paragraph

The visualization I created shows a heatmap of data accessed from AirBnB via the DATA110 course. The heatmap is created with a pheatmap function as covered in class, complete with numbers in each cell and axes labeled. I noticed that the highest proces, listings per person, and count of listings were all in Manhattan, however it isn’t the lowest availability. The lowest availability is Brooklyn, which shows the owners of the property rent it out for an average of 100 days per year.