LAB 7

LUCKY SUPERMARKET DATASET

Author

Robin Chavez

library(tidyverse)
library(ggplot2)
library(ggthemes)
library(socviz)
library(maps)
library(mapproj)
library(questionr)
library(viridis)
library(leaflet)
library(tidycensus)

GET THE DATA

LuckyUS <- read.csv("https://query.data.world/s/24f7zoc3gw5dqz6fv4opsb3tseboqw?dws=00000", header=TRUE, stringsAsFactors=FALSE)

CREATING MAP FOR LUCKY LOCATIONS

LuckyUS <- LuckyUS %>% filter(state == "CA")

LuckyUS %>% leaflet(width = "100%") %>% 
  addTiles() %>% 
  setView(-119.4179, 36.7783, zoom = 6) %>%  # Set coordinates for California
  addMarkers(lat = ~latitude, 
             lng = ~longitude, 
             popup = ~name)

Insights Map 1

  1. Concentration in Northern California: There seems to be a higher concentration of Lucky Supermarkets in the northern part of the state, particularly around the San Francisco Bay Area. This could be due to several factors, such as higher population density, greater disposable income, or established brand presence in the region.
  2. Presence in Major Cities: Lucky Supermarkets appear to be located in major cities throughout California, including Sacramento, Fresno, and Los Angeles. This suggests a focus on serving urban and suburban populations.
  3. Limited Presence in Rural Areas: The map shows fewer markers in rural areas of California, particularly in the north and central parts of the state. This could indicate a strategic decision to focus on areas with higher customer density or logistical challenges of operating stores in remote locations.
MapPalette <- colorQuantile(palette = "viridis", domain = ca_pop$estimate, n = 20)

ca_pop %>% 
  st_transform(crs = "+proj=longlat +datum=WGS84") %>% 
  leaflet(width = "100%", height = 500) %>% 
addProviderTiles(provider = "Esri.WorldStreetMap") %>% 
  addPolygons(popup = ~NAME,
              stroke = FALSE,
              smoothFactor = 0,
              fillOpacity = 0.6,
              color = ~ MapPalette(estimate)) %>% 
  addLegend("bottomright", 
            pal = MapPalette,
            values = ~ estimate,
            title = "Population Percentiles",
            opacity = 1) %>% 
  addCircleMarkers(data = LuckyUS, 
                   lat = LuckyUS$latitude,
                   lng = LuckyUS$longitude,
                   popup = LuckyUS$name,
                   weight = 1,
                   radius=4,
                   color = "red", 
                   opacity = 1)
MapPalette <- colorQuantile(palette = "viridis", domain = ca_pop$estimate, n = 20)

customIcon <- makeIcon(
  iconUrl = "https://restaurantweeklv.org/wp-content/uploads/2023/01/ltprlogo-rgbc.307313-1.png",  # Replace with your actual path
  iconWidth = 50,  
  iconHeight = 50 
)

ca_pop %>% 
  st_transform(crs = "+proj=longlat +datum=WGS84") %>% 
  leaflet(width = "100%", height = 500) %>% 
  addProviderTiles(provider = "Esri.WorldStreetMap") %>% 
  addPolygons(popup = ~NAME,
              stroke = FALSE,
              smoothFactor = 0,
              fillOpacity = 0.6,
              color = ~ MapPalette(estimate)) %>% 
  addLegend("bottomright", 
            pal = MapPalette,
            values = ~ estimate,
            title = "Population Percentiles",
            opacity = 1) %>% 
  addMarkers(data = LuckyUS, 
             lat = LuckyUS$latitude,
             lng = LuckyUS$longitude,
             popup = LuckyUS$name,
             icon = customIcon)  

Insights Map 2

  1. Lucky Supermarkets in Populous Areas: There seems to be a correlation between Lucky Supermarket locations and areas with higher population density. Many of the supermarkets are concentrated in darker green areas, particularly in the San Francisco Bay Area, Los Angeles, and Sacramento. This suggests Lucky Supermarkets might prioritize placing stores in areas with a larger customer base.
  2. Potential Targeting: Since some Lucky Supermarkets are located in less densely populated areas (lighter green), there could be other factors influencing store placement besides population density. These might include factors like proximity to competitors, underserved communities, or strategic locations along major transportation routes.