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 organization on GitHub.
Find your lab repo.
In the repo, click on the green Clone or download button, select Use HTTPS (this might already be selected by default, and if it is, you’ll see the text Clone with HTTPS as in the image below). Click on the clipboard icon to copy the repo URL.
Go to RStudio Cloud and into the course workspace. Create a New Project from Git Repo. You will need to click on the down arrow next to the New Project button to see this option.
Copy and paste the URL of your assignment repo into the dialog box:
Hit OK, and you’re good to go!
In this lab we will use the tidyverse and dsbox packages.
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'
Currently your project is called Untitled Project. Update the name of your project to be “Lab 04 - Wrangling spatial data”.
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.
Open the R Markdown (Rmd) file in your project, change the author name to your team name, and knit the document.
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 datasets we’ll use are called
laquinta from the dsbox package.
dn_ak. How many Denny’s locations are there in Alaska?
dn %>% dn_ak <- filter(state == "AK") nrow(dn_ak)
lq_ak. How many La Quinta locations are there in Alaska?
lq %>% lq_ak <- 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).