Assignment 5

library(readxl) 
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)
library(ggplot2)
library(dslabs)
setwd("~/Documents/Data 101/:Users:terrymensah:Documents:Data 101") 
df <- read_excel("Airbnb_DC_25.xlsx")
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>
ggplot(df,aes(x=room_type)) + geom_bar(fill = "red") + scale_fill_manual(values = c("blue")) 

df %>% arrange(price)  
# A tibble: 6,257 × 18
        id name     host_id host_name neighbourhood_group neighbourhood latitude
     <dbl> <chr>      <dbl> <chr>     <lgl>               <chr>            <dbl>
 1 9.98e 5 Upscale…  1.66e6 Gloria    NA                  Dupont Circl…     38.9
 2 8.32e17 Strikin…  1.76e4 Charlotte NA                  Takoma, Brig…     39.0
 3 2.10e 7 Brand N…  1.47e8 Sireenat  NA                  Capitol Hill…     38.9
 4 1.84e 6 Furnish…  9.54e6 Diane     NA                  Lamont Riggs…     39.0
 5 2.70e 7 Capitol…  1.47e8 Sireenat  NA                  Capitol Hill…     38.9
 6 1.27e 7 Relaxin…  4.15e5 Max       NA                  Mayfair, Hil…     38.9
 7 1.06e18 Stylish…  4.38e8 Eddie-Ho… NA                  Congress Hei…     38.8
 8 8.87e 5 Cozy ro…  3.15e5 John      NA                  Brightwood P…     38.9
 9 6.56e 6 Cozy ba…  3.15e5 John      NA                  Howard Unive…     38.9
10 1.31e18 Quiet c…  5.38e8 Saron     NA                  River Terrac…     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>
labs(title = "Prices based on Rooms", caption = "Dataset 2025") 
<ggplot2::labels> List of 2
 $ title  : chr "Prices based on Rooms"
 $ caption: chr "Dataset 2025"
aes(labs(title = "Prices based on Rooms", caption = "Dataset 2025") ) 
Aesthetic mapping: 
* `x` -> `labs(title = "Prices based on Rooms", caption = "Dataset 2025")`
library(readxl) 
library(tidyverse) 
library(dplyr)
library(ggplot2)
library(dslabs)
setwd("~/Documents/Data 101/:Users:terrymensah:Documents:Data 101") 
df <- read_excel("Airbnb_DC_25.xlsx")
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>
ggplot(df,aes(x=room_type, fill = room_type)) + 
geom_bar() + 
  scale_fill_manual(values = c("blue", "red","blue", "red")) + labs(title = "Prices based on Rooms",caption = "Dataset 2025") 

df %>% arrange(price)  
# A tibble: 6,257 × 18
        id name     host_id host_name neighbourhood_group neighbourhood latitude
     <dbl> <chr>      <dbl> <chr>     <lgl>               <chr>            <dbl>
 1 9.98e 5 Upscale…  1.66e6 Gloria    NA                  Dupont Circl…     38.9
 2 8.32e17 Strikin…  1.76e4 Charlotte NA                  Takoma, Brig…     39.0
 3 2.10e 7 Brand N…  1.47e8 Sireenat  NA                  Capitol Hill…     38.9
 4 1.84e 6 Furnish…  9.54e6 Diane     NA                  Lamont Riggs…     39.0
 5 2.70e 7 Capitol…  1.47e8 Sireenat  NA                  Capitol Hill…     38.9
 6 1.27e 7 Relaxin…  4.15e5 Max       NA                  Mayfair, Hil…     38.9
 7 1.06e18 Stylish…  4.38e8 Eddie-Ho… NA                  Congress Hei…     38.8
 8 8.87e 5 Cozy ro…  3.15e5 John      NA                  Brightwood P…     38.9
 9 6.56e 6 Cozy ba…  3.15e5 John      NA                  Howard Unive…     38.9
10 1.31e18 Quiet c…  5.38e8 Saron     NA                  River Terrac…     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>

In this bar chart it tells how many people rented the spaces based on the room types. From what it appears the entire home/ apt has to most counts. The private room has the second highest counts. The hotel has a lower bar and shared rooms have the lowest out of all. In conclusion the chart summarizes that  people preferred the homes and apartments over any rooms.