hw2/3 code
install.packages(“tidyverse”) install.packages(“dplyr”)
install.packages(“grepl”)
library(“tidyverse”) library(“dplyr”) library(“tidyr”)
library(readxl) hotel_bookings <- read_excel(“hotel_bookings.xlsx”) View(hotel_bookings)
hotel, kind of hotel, text
is_canceled, number of cancellations, numeric
lead_time, how many days in advance the bookings were made
arrival_date_year, year of booking, date
arrival_date_month, month of booking, date
arrival_date_week_number, week number of the year that the booking was in, date
arrival_date_day_of_month, day of the month the arrival, date
stays_in_weekend_nights, how many weekend nights the bookings covered, numeric
stays_in_week_nights, how many week nights the bookings covered, numeric
adults, number of adults associated with the bookings, numeric
children, number of children associated with the bookings, numeric
babies, number of babies associated with the bookings, numeric
meal, not sure, numeric
country, the country the hotel is in, text
market_segment, not sure, text
distribution_channel, not sure, text
is_repeated_guest, if the guest stayed at that hotel before, binary
previous_cancellations, if the guest had previously canceled a reservation, binary
previous_bookings_not_canceled, if the guest had previously had a reservation that they did not, binary
reserved_room_type, type of room reserved, letter
assigned_room_type, type of room received, letter
booking_changes, number of times reservation was changed, numeric
deposit_type, if a deposit was put on the room, text
agent, not sure, numeric
company, not sure, numeric
days_in_waiting_list, how long a reservation was on a waiting list
customer_type, not sure, text
adr, not sure, numeric
required_car_parking_spaces, number of vehicle parking spaces required by the reservation, numeric
total_of_special_requests, number of special requests, numeric
reservation_status, what was the status of the reservation when the data was collected, text
reservation_status_date, the date when the reservation_status was recorded, date
usa_hotels <- filter(hotel_bookings, country == USA) view(usa_hotels)
usa_hotels isolates the hotels in the datasheet that are in theUnited States
max_wk_nignts_usa <- arrange(usa_hotels, (desc(stays_in_week_nights)) view(max_wk_nignts_usa)
max_wk_nignts_usa shows the hotels in the United States ranked by how long stays during the week were
R Markdown
This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.
When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
speed dist
Min. : 4.0 Min. : 2.00
1st Qu.:12.0 1st Qu.: 26.00
Median :15.0 Median : 36.00
Mean :15.4 Mean : 42.98
3rd Qu.:19.0 3rd Qu.: 56.00
Max. :25.0 Max. :120.00
Including Plots
You can also embed plots, for example:
Note that the echo = FALSE
parameter was added to the code chunk to prevent printing of the R code that generated the plot.
Reuse
Text and figures are licensed under Creative Commons Attribution CC BY-NC 4.0. The figures that have been reused from other sources don't fall under this license and can be recognized by a note in their caption: "Figure from ...".
Citation
For attribution, please cite this work as
Mulvey (2022, Feb. 20). Data Analytics and Computational Social Science: HW 2 Try 2. Retrieved from https://github.com/DACSS/dacss_course_website/posts/httpsrpubscomhmuleyumass867799/
BibTeX citation
@misc{mulvey2022hw,
author = {Mulvey, Henry},
title = {Data Analytics and Computational Social Science: HW 2 Try 2},
url = {https://github.com/DACSS/dacss_course_website/posts/httpsrpubscomhmuleyumass867799/},
year = {2022}
}