%>%
hotels filter(
"USA",
country ____
lead_time ____ ____ )
Tidyverse activity 1: Hotels
Getting Started
Navigate to your CMSC 121 RStudio project
Create a new Quarto Document for this in-class activity called
tidyverse_in_class_activity_1.qmd
Load the
tidyverse
packageIn the console, run the command
glimpse(hotels)
and peruse the information it generates about the data frame.
Exercises
Question 1
Are people traveling on a whim? Let’s see…
Copy the code below into your file, fill in the blanks so that it will filter for hotel bookings where the guest is not from the US (country code “USA”) and the lead_time
is less than 1 day.
Question 2
How many bookings involve at least 1 child **or** baby?
Copy the below code chunk into your Quarto and replace:
[AT LEAST] with the logical operator for “at least” (in two places)
[OR] with the logical operator for “or”
%>%
hotels filter(
1 [OR] babies [AT LEAST] 1
children [AT LEAST] )
Question 3
Do you think it’s more likely to find bookings with children or babies in city hotels or resort hotels? Test your intuition. Using filter()
, determine the number of bookings in resort hotels that have more than 1 child OR baby in the room. Then, do the same for city hotels, and compare the numbers of rows in the resulting filtered data frames. In addition to your code, put your conclusion in a comment in the file.