Assignment 5

Author

Surafel Haile

Assignment 5 :

library(readxl)
df <- read_excel("Airbnb_DC_25.csv")
df
# 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>
colSums(is.na(df))
                            id                           name 
                             0                              0 
                       host_id                      host_name 
                             0                              2 
           neighbourhood_group                  neighbourhood 
                          6257                              0 
                      latitude                      longitude 
                             0                              0 
                     room_type                          price 
                             0                           1488 
                minimum_nights              number_of_reviews 
                             0                              0 
                   last_review              reviews_per_month 
                          1236                           1236 
calculated_host_listings_count               availability_365 
                             0                              0 
         number_of_reviews_ltm                        license 
                             0                           1560 
library(dplyr)
Warning: package 'dplyr' was built under R version 4.5.3

Attaching package: 'dplyr'
The following objects are masked from 'package:stats':

    filter, lag
The following objects are masked from 'package:base':

    intersect, setdiff, setequal, union
library(ggplot2)
airbnb2 <-df|> filter(!is.na(price), price < 500)
airbnb2 |> ggplot(aes(room_type, price, fill = room_type)) +  labs(title = "Airbnb Prices by Room Type",subtitle = "Comparison of listing prices under $500",x = "Room Type",y = "Price (USD)",caption = "Source: Airbnb dataset" )+ 
geom_boxplot() +
 scale_fill_discrete(name = "room_type", labels = c("Entire home/app", "Hotel room","Private room", "Shared room"))

This visualization compares prices and room types, including entire homes, private rooms, and shared rooms. If you look at the Y- axis, you’ll see that the data set was filtered to remove missing values and extreme prices above 500 dollars. The box plots shows the distribution, median, and spread. A pattern that we can observe is that entire homes and hotel rooms are more expensive and have a wider range of prices than private rooms and shared ones.