In this lab we revisit the Denny’s and La Quinta Inn and Suites data we visualized in the previous lab.
Go to the course GitHub organization and locate your homework repo, clone it in RStudio and open the R Markdown document. Knit the document to make sure it compiles without errors.
Before we introduce the data, let’s warm up with some simple exercises. Update the YAML of your R Markdown file with your information, knit, commit, and push your changes. Make sure to commit with a meaningful commit message. Then, go to your repo on GitHub and confirm that your changes are visible in your Rmd and md files. If anything is missing, commit and push again.
We’ll use the tidyverse package for much of the data wrangling and visualisation and the data lives in the dsbox package. These packages are already installed for you. You can load them by running the following in your Console:
library(tidyverse)
library(dsbox)
Remember that the datasets we’ll use are called dennys
and laquinta
from the dsbox package. Since the datasets are distributed with the package, we don’t need to load them separately; they become available to us when we load the package. You can find out more about the datasets by inspecting their documentation, which you can access by running ?dennys
and ?laquinta
in the Console or using the Help menu in RStudio to search for dennys
or laquinta
. You can also find this information here and here.
dn_ak
. How many Denny’s locations are there in Alaska?<- dennys %>%
dn_ak filter(state == "AK")
nrow(dn_ak)
## [1] 3
lq_ak
. How many La Quinta locations are there in Alaska?<- laquinta %>%
lq_ak filter(state == "AK")
nrow(lq_ak)
## [1] 2
Next we’ll calculate the distance between all Denny’s and all La Quinta locations in Alaska. Let’s take this step by step:
Step 1: There are 3 Denny’s and 2 La Quinta locations in Alaska. (If you answered differently above, you might want to recheck your answers.)
Step 2: Let’s focus on the first Denny’s location. We’ll need to calculate two distances for it: (1) distance between Denny’s 1 and La Quinta 1 and (2) distance between Denny’s 1 and La Quinta (2).