Lab 05 - La Quinta is Spanish for next to Denny’s, Pt. 2

Wrangling spatial data

In this lab we revisit the Denny’s and La Quinta Inn and Suites data we visualized in the previous lab.

Getting started

Packages

In this lab we will use the tidyverse and dsbox packages.

library(tidyverse) 
library(dsbox) 

Housekeeping

Password caching

If you would like your git password cached for a week for this project, type the following in the Terminal:

git config --global credential.helper 'cache --timeout 604800'

Project name

Currently your project is called Untitled Project. Update the name of your project to be “Lab 04 - Wrangling spatial data”.

Warm up

Pick one team member to complete the steps in this section while the others contribute to the discussion but do not actually touch the files on their computer.

Before we introduce the data, let’s warm up with some simple exercises.

YAML

Open the R Markdown (Rmd) file in your project, change the author name to your team name, and knit the document.

Commiting and pushing changes:

Pulling changes

Now, the remaining team members who have not been concurrently making these changes on their projects should click on the Pull button in their Git pane and observe that the changes are now reflected on their projects as well.

The data

The datasets we’ll use are called dennys and laquinta from the dsbox package.

Exercises

  1. Filter the Denny’s dataframe for Alaska (AK) and save the result as dn_ak. How many Denny’s locations are there in Alaska?
dn_ak <- dn %>%
  filter(state == "AK")
nrow(dn_ak)
  1. Filter the La Quinta dataframe for Alaska (AK) and save the result as lq_ak. How many La Quinta locations are there in Alaska?
lq_ak <- lq %>%
  filter(state == "AK")
nrow(lq_ak)

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).