Week1_Assignment

Author

Theresa Benny

Approach

For this analysis, I plan to explore New York City Airbnb listings to understand factors that influence rental prices and availability across different neighborhoods and room types. The primary goal is to clean and transform the dataset into a format suitable for analysis, identify key variables, and prepare it for potential predictive modeling in later assignments.

To tackle this problem, I will: - Source a publicly accessible NYC Airbnb dataset that includes pricing, room type, neighborhood, and availability information. - Subset relevant columns and ensure meaningful column names are used. - Identify a potential target variable (price) and explore patterns across different categories such as neighborhood group and room type. - Handle data cleaning tasks, such as removing extreme outliers (e.g., listings with unrealistically high prices or minimum nights) and addressing missing values.

Anticipated data challenges include: - Large dataset size (~48,000 listings), which may require efficient data handling. - Missing or inconsistent values for certain variables (e.g., reviews, availability). - Outliers that could distort summary statistics or visualizations.

This approach will allow me to produce a clean, analyzable dataset and provide a foundation for further exploratory analysis or predictive modeling in later weeks.

url <- “https://huggingface.co/datasets/gradio/NYC-Airbnb-Open-Data/resolve/main/AB_NYC_2019.csv”

##Code Base

library(tidyverse)
── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr     1.1.4     ✔ readr     2.1.6
✔ forcats   1.0.1     ✔ stringr   1.6.0
✔ ggplot2   4.0.1     ✔ tibble    3.3.1
✔ lubridate 1.9.4     ✔ tidyr     1.3.2
✔ purrr     1.2.1     
── 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
library(gt)

# Load the dataset
url <- "https://raw.githubusercontent.com/TheresaBenny/Data-607/refs/heads/main/AB_NYC_2019.csv"

# Displaying raw data 
df <- read_csv(
  file = url, 
  show_col_types = FALSE,
  progress = FALSE
  
)

glimpse (df)
Rows: 48,895
Columns: 16
$ id                             <dbl> 2539, 2595, 3647, 3831, 5022, 5099, 512…
$ name                           <chr> "Clean & quiet apt home by the park", "…
$ host_id                        <dbl> 2787, 2845, 4632, 4869, 7192, 7322, 735…
$ host_name                      <chr> "John", "Jennifer", "Elisabeth", "LisaR…
$ neighbourhood_group            <chr> "Brooklyn", "Manhattan", "Manhattan", "…
$ neighbourhood                  <chr> "Kensington", "Midtown", "Harlem", "Cli…
$ latitude                       <dbl> 40.64749, 40.75362, 40.80902, 40.68514,…
$ longitude                      <dbl> -73.97237, -73.98377, -73.94190, -73.95…
$ room_type                      <chr> "Private room", "Entire home/apt", "Pri…
$ price                          <dbl> 149, 225, 150, 89, 80, 200, 60, 79, 79,…
$ minimum_nights                 <dbl> 1, 1, 3, 1, 10, 3, 45, 2, 2, 1, 5, 2, 4…
$ number_of_reviews              <dbl> 9, 45, 0, 270, 9, 74, 49, 430, 118, 160…
$ last_review                    <date> 2018-10-19, 2019-05-21, NA, 2019-07-05…
$ reviews_per_month              <dbl> 0.21, 0.38, NA, 4.64, 0.10, 0.59, 0.40,…
$ calculated_host_listings_count <dbl> 6, 2, 1, 1, 1, 1, 1, 1, 1, 4, 1, 1, 3, …
$ availability_365               <dbl> 365, 355, 365, 194, 0, 129, 0, 220, 0, …
#Dump to GT Attempt #1 failed because system could not handle 48895 roww. Attempt #2 with less rows using slice_head function
df |>
  slice_head(n = 50) |>
  gt()
id name host_id host_name neighbourhood_group neighbourhood latitude longitude room_type price minimum_nights number_of_reviews last_review reviews_per_month calculated_host_listings_count availability_365
2539 Clean & quiet apt home by the park 2787 John Brooklyn Kensington 40.64749 -73.97237 Private room 149 1 9 2018-10-19 0.21 6 365
2595 Skylit Midtown Castle 2845 Jennifer Manhattan Midtown 40.75362 -73.98377 Entire home/apt 225 1 45 2019-05-21 0.38 2 355
3647 THE VILLAGE OF HARLEM....NEW YORK ! 4632 Elisabeth Manhattan Harlem 40.80902 -73.94190 Private room 150 3 0 NA NA 1 365
3831 Cozy Entire Floor of Brownstone 4869 LisaRoxanne Brooklyn Clinton Hill 40.68514 -73.95976 Entire home/apt 89 1 270 2019-07-05 4.64 1 194
5022 Entire Apt: Spacious Studio/Loft by central park 7192 Laura Manhattan East Harlem 40.79851 -73.94399 Entire home/apt 80 10 9 2018-11-19 0.10 1 0
5099 Large Cozy 1 BR Apartment In Midtown East 7322 Chris Manhattan Murray Hill 40.74767 -73.97500 Entire home/apt 200 3 74 2019-06-22 0.59 1 129
5121 BlissArtsSpace! 7356 Garon Brooklyn Bedford-Stuyvesant 40.68688 -73.95596 Private room 60 45 49 2017-10-05 0.40 1 0
5178 Large Furnished Room Near B'way 8967 Shunichi Manhattan Hell's Kitchen 40.76489 -73.98493 Private room 79 2 430 2019-06-24 3.47 1 220
5203 Cozy Clean Guest Room - Family Apt 7490 MaryEllen Manhattan Upper West Side 40.80178 -73.96723 Private room 79 2 118 2017-07-21 0.99 1 0
5238 Cute & Cozy Lower East Side 1 bdrm 7549 Ben Manhattan Chinatown 40.71344 -73.99037 Entire home/apt 150 1 160 2019-06-09 1.33 4 188
5295 Beautiful 1br on Upper West Side 7702 Lena Manhattan Upper West Side 40.80316 -73.96545 Entire home/apt 135 5 53 2019-06-22 0.43 1 6
5441 Central Manhattan/near Broadway 7989 Kate Manhattan Hell's Kitchen 40.76076 -73.98867 Private room 85 2 188 2019-06-23 1.50 1 39
5803 Lovely Room 1, Garden, Best Area, Legal rental 9744 Laurie Brooklyn South Slope 40.66829 -73.98779 Private room 89 4 167 2019-06-24 1.34 3 314
6021 Wonderful Guest Bedroom in Manhattan for SINGLES 11528 Claudio Manhattan Upper West Side 40.79826 -73.96113 Private room 85 2 113 2019-07-05 0.91 1 333
6090 West Village Nest - Superhost 11975 Alina Manhattan West Village 40.73530 -74.00525 Entire home/apt 120 90 27 2018-10-31 0.22 1 0
6848 Only 2 stops to Manhattan studio 15991 Allen & Irina Brooklyn Williamsburg 40.70837 -73.95352 Entire home/apt 140 2 148 2019-06-29 1.20 1 46
7097 Perfect for Your Parents + Garden 17571 Jane Brooklyn Fort Greene 40.69169 -73.97185 Entire home/apt 215 2 198 2019-06-28 1.72 1 321
7322 Chelsea Perfect 18946 Doti Manhattan Chelsea 40.74192 -73.99501 Private room 140 1 260 2019-07-01 2.12 1 12
7726 Hip Historic Brownstone Apartment with Backyard 20950 Adam And Charity Brooklyn Crown Heights 40.67592 -73.94694 Entire home/apt 99 3 53 2019-06-22 4.44 1 21
7750 Huge 2 BR Upper East Cental Park 17985 Sing Manhattan East Harlem 40.79685 -73.94872 Entire home/apt 190 7 0 NA NA 2 249
7801 Sweet and Spacious Brooklyn Loft 21207 Chaya Brooklyn Williamsburg 40.71842 -73.95718 Entire home/apt 299 3 9 2011-12-28 0.07 1 0
8024 CBG CtyBGd HelpsHaiti rm#1:1-4 22486 Lisel Brooklyn Park Slope 40.68069 -73.97706 Private room 130 2 130 2019-07-01 1.09 6 347
8025 CBG Helps Haiti Room#2.5 22486 Lisel Brooklyn Park Slope 40.67989 -73.97798 Private room 80 1 39 2019-01-01 0.37 6 364
8110 CBG Helps Haiti Rm #2 22486 Lisel Brooklyn Park Slope 40.68001 -73.97865 Private room 110 2 71 2019-07-02 0.61 6 304
8490 MAISON DES SIRENES1,bohemian apartment 25183 Nathalie Brooklyn Bedford-Stuyvesant 40.68371 -73.94028 Entire home/apt 120 2 88 2019-06-19 0.73 2 233
8505 Sunny Bedroom Across Prospect Park 25326 Gregory Brooklyn Windsor Terrace 40.65599 -73.97519 Private room 60 1 19 2019-06-23 1.37 2 85
8700 Magnifique Suite au N de Manhattan - vue Cloitres 26394 Claude & Sophie Manhattan Inwood 40.86754 -73.92639 Private room 80 4 0 NA NA 1 0
9357 Midtown Pied-a-terre 30193 Tommi Manhattan Hell's Kitchen 40.76715 -73.98533 Entire home/apt 150 10 58 2017-08-13 0.49 1 75
9518 SPACIOUS, LOVELY FURNISHED MANHATTAN BEDROOM 31374 Shon Manhattan Inwood 40.86482 -73.92106 Private room 44 3 108 2019-06-15 1.11 3 311
9657 Modern 1 BR / NYC / EAST VILLAGE 21904 Dana Manhattan East Village 40.72920 -73.98542 Entire home/apt 180 14 29 2019-04-19 0.24 1 67
9668 front room/double bed 32294 Ssameer Or Trip Manhattan Harlem 40.82245 -73.95104 Private room 50 3 242 2019-06-01 2.04 3 355
9704 Spacious 1 bedroom in luxe building 32045 Teri Manhattan Harlem 40.81305 -73.95466 Private room 52 2 88 2019-06-14 1.42 1 255
9782 Loft in Williamsburg Area w/ Roof 32169 Andrea Brooklyn Greenpoint 40.72219 -73.93762 Private room 55 4 197 2019-06-15 1.65 3 284
9783 back room/bunk beds 32294 Ssameer Or Trip Manhattan Harlem 40.82130 -73.95318 Private room 50 3 273 2019-07-01 2.37 3 359
10452 Large B&B Style rooms 35935 Angela Brooklyn Bedford-Stuyvesant 40.68310 -73.95473 Private room 70 1 74 2019-05-12 0.66 2 269
10962 Lovely room 2 & garden; Best area, Legal rental 9744 Laurie Brooklyn South Slope 40.66869 -73.98780 Private room 89 4 168 2019-06-21 1.41 3 340
11452 Clean and Quiet in Brooklyn 7355 Vt Brooklyn Bedford-Stuyvesant 40.68876 -73.94312 Private room 35 60 0 NA NA 1 365
11708 Cute apt in artist's home 44145 Tyrome Brooklyn Bushwick 40.70186 -73.92745 Entire home/apt 85 2 231 2019-06-22 1.96 2 22
11943 Country space in the city 45445 Harriet Brooklyn Flatbush 40.63702 -73.96327 Private room 150 1 0 NA NA 1 365
12048 LowerEastSide apt share shortterm 1 7549 Ben Manhattan Lower East Side 40.71401 -73.98917 Shared room 40 1 214 2019-07-05 1.81 4 188
12192 ENJOY Downtown NYC! 46978 Edward Manhattan East Village 40.72290 -73.98199 Private room 68 2 245 2019-06-21 2.08 2 96
12299 Beautiful Sunny Park Slope Brooklyn 47610 Abdul Brooklyn South Slope 40.66278 -73.97966 Entire home/apt 120 3 15 2019-05-27 0.39 1 345
12303 1bdr w private bath. in lofty apt 47618 Yolande Brooklyn Fort Greene 40.69673 -73.97584 Private room 120 7 25 2018-09-30 0.23 1 311
12318 West Side Retreat 16800 Cyn Manhattan Upper West Side 40.79009 -73.97927 Private room 135 4 81 2019-06-16 0.69 1 273
12343 BEST BET IN HARLEM 47727 Earl Manhattan Harlem 40.81175 -73.94478 Entire home/apt 150 7 97 2019-06-13 0.84 1 309
12627 Entire apartment in central Brooklyn neighborhood. 49670 Rana Brooklyn Prospect-Lefferts Gardens 40.65944 -73.96238 Entire home/apt 150 29 11 2019-06-05 0.49 1 95
12937 1 Stop fr. Manhattan! Private Suite,Landmark Block 50124 Orestes Queens Long Island City 40.74771 -73.94740 Private room 130 3 248 2019-07-01 2.25 1 215
12940 Charming Brownstone 3 - Near PRATT 50148 Adreinne Brooklyn Bedford-Stuyvesant 40.68111 -73.95591 Entire home/apt 110 7 61 2019-05-25 0.52 1 265
13050 bright and stylish duplex 50846 Jennifer Brooklyn Bedford-Stuyvesant 40.68554 -73.94090 Entire home/apt 115 3 11 2017-01-01 0.10 1 0
13394 Fort Greene brownstone 52335 Alexander Brooklyn Fort Greene 40.69142 -73.97376 Private room 80 3 135 2019-06-17 1.16 2 192
#Subset
df1 <- df[1:5, c(1,2,4,5,10)]

df1 |>
  gt()
id name host_name neighbourhood_group price
2539 Clean & quiet apt home by the park John Brooklyn 149
2595 Skylit Midtown Castle Jennifer Manhattan 225
3647 THE VILLAGE OF HARLEM....NEW YORK ! Elisabeth Manhattan 150
3831 Cozy Entire Floor of Brownstone LisaRoxanne Brooklyn 89
5022 Entire Apt: Spacious Studio/Loft by central park Laura Manhattan 80