MendozaM_Week5HW

Maria Mendoza - DATA110 HW 5 - Airbnb DC

#install.packages("readxl")
library(readxl)
airbnb<-read_excel("Airbnb_DC_25.csv")
airbnb
# A tibble: 6,257 × 18
      id name       host_id host_name neighbourhood_group neighbourhood latitude
   <dbl> <chr>        <dbl> <chr>     <lgl>               <chr>            <dbl>
 1  3686 Vita's Hi…    4645 Vita      NA                  Historic Ana…     38.9
 2  3943 Historic …    5059 Vasa      NA                  Edgewood, Bl…     38.9
 3  4197 Capitol H…    5061 Sandra    NA                  Capitol Hill…     38.9
 4  4529 Bertina's…    5803 Bertina   NA                  Eastland Gar…     38.9
 5  5589 Cozy apt …    6527 Ami       NA                  Kalorama Hei…     38.9
 6  7103 Lovely gu…   17633 Charlotte NA                  Spring Valle…     38.9
 7 11785 Sanctuary…   32015 Teresa    NA                  Cathedral He…     38.9
 8 12442 Peaches &…   32015 Teresa    NA                  Cathedral He…     38.9
 9 13744 Heart of …   53927 Victoria  NA                  Columbia Hei…     38.9
10 14218 Quiet Com…   32015 Teresa    NA                  Cathedral He…     38.9
# ℹ 6,247 more rows
# ℹ 11 more variables: longitude <dbl>, room_type <chr>, price <dbl>,
#   minimum_nights <dbl>, number_of_reviews <dbl>, last_review <dttm>,
#   reviews_per_month <dbl>, calculated_host_listings_count <dbl>,
#   availability_365 <dbl>, number_of_reviews_ltm <dbl>, license <chr>
#install.packages("tidyverse")
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
library(dplyr)
#observe the data
head(airbnb)
# A tibble: 6 × 18
     id name        host_id host_name neighbourhood_group neighbourhood latitude
  <dbl> <chr>         <dbl> <chr>     <lgl>               <chr>            <dbl>
1  3686 Vita's Hid…    4645 Vita      NA                  Historic Ana…     38.9
2  3943 Historic R…    5059 Vasa      NA                  Edgewood, Bl…     38.9
3  4197 Capitol Hi…    5061 Sandra    NA                  Capitol Hill…     38.9
4  4529 Bertina's …    5803 Bertina   NA                  Eastland Gar…     38.9
5  5589 Cozy apt i…    6527 Ami       NA                  Kalorama Hei…     38.9
6  7103 Lovely gue…   17633 Charlotte NA                  Spring Valle…     38.9
# ℹ 11 more variables: longitude <dbl>, room_type <chr>, price <dbl>,
#   minimum_nights <dbl>, number_of_reviews <dbl>, last_review <dttm>,
#   reviews_per_month <dbl>, calculated_host_listings_count <dbl>,
#   availability_365 <dbl>, number_of_reviews_ltm <dbl>, license <chr>
names(airbnb)
 [1] "id"                             "name"                          
 [3] "host_id"                        "host_name"                     
 [5] "neighbourhood_group"            "neighbourhood"                 
 [7] "latitude"                       "longitude"                     
 [9] "room_type"                      "price"                         
[11] "minimum_nights"                 "number_of_reviews"             
[13] "last_review"                    "reviews_per_month"             
[15] "calculated_host_listings_count" "availability_365"              
[17] "number_of_reviews_ltm"          "license"                       
airbnb_type<-airbnb |> group_by(room_type)
airbnb_popular<-filter(airbnb_type,number_of_reviews>250)
count(airbnb_popular)
# A tibble: 3 × 2
# Groups:   room_type [3]
  room_type           n
  <chr>           <int>
1 Entire home/apt   348
2 Hotel room          1
3 Private room       78
ggplot(airbnb_popular,aes(x=room_type))+
  geom_bar()

Seems like there aren’t any “shared room”-type Airbnbs with more than 250 reviews

airbnb_type_price<-airbnb_popular |> 
  ggplot(aes(x=room_type,y=price, fill=room_type))+
  labs(x="AirBnB Type",y="Price Per Night",
       title="Side-by-Side Boxplot of DC AirBnB Types and Price per Night",
       caption="Source: DATA110 Class Dataset Repository, AirBnB")+
  geom_boxplot()+
  scale_fill_discrete(name="Type",labels=c("Entire home/apt","Hotel Room","Private Room"))
airbnb_type_price
Warning: Removed 41 rows containing non-finite outside the scale range
(`stat_boxplot()`).

The visualization I created is a side-by-side box plot of using the type of Airbnb for the x-axis and the price per night as the y-axis, with a filter so that only the most popular Airbnbs with more than 250 reviews would be shown. From this graph, you can see the median prices of each type of room (entire home/apartment, hotel, and private room) and also the minimums and maximums. You can also notice that it costs less to book a private room over an entire home/apt and hotel per night in DC. Also that there is only one observation for a hotel type Airbnb that has over 250 reviews.