Lab 04 - La Quinta is Spanish for next to Denny’s, Pt. 1

Brady May 5/18/26

Load packages and data

library(tidyverse) 
library(dsbox) 
states <- read_csv("states.csv")

Exercise 1

  1. What are the dimensions of the Dennys dataset?
dim(dennys)
## [1] 1643    6

The Denny’s dataset has 1643 rows and 7 columns Each row represents a Denny’s location and the variables include info like the address, city, state, etc.

What are the dimensions of the La Quinta dataset?

dim(laquinta)
## [1] 909   6

The La Quinta has 906 rows and 6 columns. each row represents a La Quinta hotel and variables include info like the address, city, state, etc

  1. Take a look at the websites that the data come from. Are there any La Quintas locations outside the US? If so, which counries? What about Dennys?

Yes outside of the US, they are located in Canada, Mexico, Turkey, Ecuador, and Coloumbia. Dennys only operates in US

  1. Now take a look at the data. What would be some ways of determining whether or not either establishment has any locations outside the US using just the data.

A few ways we could determine if the locations are in the US would be checking for the state abbreviations in the data. you could also look at the zipcodes or address to figure out the location.

  1. Find the Denny’s locations that are outside the US, if any.
dennys %>%
  filter(!(state %in% states$abbreviation))
## # A tibble: 0 × 6
## # ℹ 6 variables: address <chr>, city <chr>, state <chr>, zip <chr>,
## #   longitude <dbl>, latitude <dbl>

There are no Dennys outside the US from the dataset

  1. Add a country variable to the Denny’s dataset and set all observations equal to “United States”.
dennys <- dennys %>%
  mutate(country = "United States")

With this, the variable country will have US assigned to every observation.

  1. Find the La Quinta locations that are outside the US, and figure out which country they are in. This might require some googling. Take notes, you will need to use this information in the next exercise.
laquinta %>%
  filter(!(state %in% states$abbreviation)) %>%
  count(state)
## # A tibble: 11 × 2
##    state     n
##    <chr> <int>
##  1 AG        1
##  2 ANT       1
##  3 BC        1
##  4 CH        1
##  5 FM        1
##  6 NL        3
##  7 ON        1
##  8 PU        2
##  9 QR        1
## 10 SL        1
## 11 VE        1
  1. Add a country variable to the La Quinta dataset. Use the case_when function to populate this variable. You’ll need to refer to your notes from Exercise 7 about which country the non-US locations are in. Here is some starter code to get you going:
laquinta %>%
  mutate(country = case_when(
    state %in% state.abb     ~ "United States",
    state %in% c("ON", "BC") ~ "Canada",
    state == "ANT"           ~ "Colombia",
    state == "FM" ~ "Honduras",
    state %in% c("AG", "QR", "CH", "NL", "VE", "PU", "SL") ~ "Mexico"
  )) %>%
  filter(country == "United States")
## # A tibble: 895 × 7
##    address                         city   state zip   longitude latitude country
##    <chr>                           <chr>  <chr> <chr>     <dbl>    <dbl> <chr>  
##  1 793 W. Bel Air Avenue           "\nAb… MD    21001     -76.2     39.5 United…
##  2 3018 CatClaw Dr                 "\nAb… TX    79606     -99.8     32.4 United…
##  3 3501 West Lake Rd               "\nAb… TX    79601     -99.7     32.5 United…
##  4 184 North Point Way             "\nAc… GA    30102     -84.7     34.1 United…
##  5 2828 East Arlington Street      "\nAd… OK    74820     -96.6     34.8 United…
##  6 14925 Landmark Blvd             "\nAd… TX    75254     -96.8     33.0 United…
##  7 909 East Frontage Rd            "\nAl… TX    78516     -98.1     26.2 United…
##  8 2116 Yale Blvd Southeast        "\nAl… NM    87106    -107.      35.1 United…
##  9 7439 Pan American Fwy Northeast "\nAl… NM    87109    -107.      35.2 United…
## 10 2011 Menaul Blvd Northeast      "\nAl… NM    87107    -107.      35.1 United…
## # ℹ 885 more rows
  1. Which states have the most and fewest Denny’s locations? What about La Quinta? Is this surprising? Why or why not?
dennys %>% count(state, sort = TRUE)
## # A tibble: 51 × 2
##    state     n
##    <chr> <int>
##  1 CA      403
##  2 TX      200
##  3 FL      140
##  4 AZ       83
##  5 IL       56
##  6 NY       56
##  7 WA       49
##  8 OH       44
##  9 MO       42
## 10 PA       40
## # ℹ 41 more rows
laquinta %>% count(state, sort = TRUE)
## # A tibble: 59 × 2
##    state     n
##    <chr> <int>
##  1 TX      237
##  2 FL       74
##  3 CA       56
##  4 GA       41
##  5 TN       30
##  6 OK       29
##  7 LA       28
##  8 CO       27
##  9 NM       19
## 10 NY       19
## # ℹ 49 more rows

Texas and California have the most locations which isnt surprising as they are the two biggest states.

  1. Which states have the most Denny’s locations per thousand square miles? What about La Quinta?
dennys <- dennys %>%
  mutate(establishment = "Denny's")
laquinta <- laquinta %>%
  mutate(establishment = "La Quinta")
dn_lq <- bind_rows(dennys, laquinta)

ggplot(dn_lq, mapping = aes(x = longitude, y = latitude, color = establishment)) +
  geom_point()

From this data, smaller states tend to rank highest for Dennys and La Quinta per thousand square miles

  1. Filter the data for observations in North Carolina only, and recreate the plot. You should also adjust the transparency of the points, by setting the alpha level, so that it’s easier to see the overplotted ones. Visually, does Mitch Hedberg’s joke appear to hold here?
dn_lq %>%
  filter(state == "NC") %>%
  ggplot(aes(x = longitude, y = latitude, color = establishment)) +
  geom_point(alpha = 0.5, size = 2) +
  scale_color_manual(values = c("Denny's" = "blue", "La Quinta" = "green"))

  labs(
    title = "Dennys and La Quinta in North Carolina",
    subtitle = "Mitch Hedbergs Joke: La Quinta is Spanish for next to Dennys",
    x = "Longitude",
    y = "Latitude",
    color = "Establishment)" +
  theme_minimal() +
  theme(legend.position = "bottom")
  )
## <ggplot2::labels> List of 5
##  $ x       : chr "Longitude"
##  $ y       : chr "Latitude"
##  $ colour  : NULL
##  $ title   : chr "Dennys and La Quinta in North Carolina"
##  $ subtitle: chr "Mitch Hedbergs Joke: La Quinta is Spanish for next to Dennys"

The jokes does appear to hold in North Carolina because many of the locations are very close

  1. Now filter the data for observations in Texas only, and recreate the plot, with an appropriate alpha level. Visually, does Mitch Hedberg’s joke appear to hold here?
dn_lq %>%
  filter(state == "TX") %>%
  ggplot(aes(x = longitude, y = latitude, color = establishment)) +
  geom_point(alpha = 0.5, size = 2) +
  scale_color_manual(values = c("Denny's" = "green", "La Quinta" = "brown"))

  labs(
    title = "Dennys and La Quinta in North Carolina",
    subtitle = "Mitch Hedbergs Joke: La Quinta is Spanish for next to Dennys",
    x = "Longitude",
    y = "Latitude",
    color = "Establishment)" +
  theme_minimal() +
  theme(legend.position = "bottom")
  )
## <ggplot2::labels> List of 5
##  $ x       : chr "Longitude"
##  $ y       : chr "Latitude"
##  $ colour  : NULL
##  $ title   : chr "Dennys and La Quinta in North Carolina"
##  $ subtitle: chr "Mitch Hedbergs Joke: La Quinta is Spanish for next to Dennys"

The joke holds in Texas. There is clustering between Dennys and La Quinta.