Warning: package 'ggthemes' was built under R version 4.3.3
library(socviz)
Warning: package 'socviz' was built under R version 4.3.3
library(maps)
Warning: package 'maps' was built under R version 4.3.3
library(mapproj)
Warning: package 'mapproj' was built under R version 4.3.3
library(viridis)
Warning: package 'viridis' was built under R version 4.3.2
Loading required package: viridisLite
Attaching package: 'viridis'
The following object is masked from 'package:maps':
unemp
Lowes - Store Locations
library(tidyverse)
── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr 1.1.2 ✔ readr 2.1.4
✔ forcats 1.0.0 ✔ stringr 1.5.0
✔ lubridate 1.9.2 ✔ tibble 3.2.1
✔ purrr 1.0.2 ✔ tidyr 1.3.0
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag() masks stats::lag()
✖ purrr::map() masks maps::map()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(tidycensus)
Warning: package 'tidycensus' was built under R version 4.3.3
library(leaflet)
Warning: package 'leaflet' was built under R version 4.3.3
library(stringr)#census_api_key("3e87a14c2e4c3c095111a5b79353762d398009d1", install=TRUE) # use this to install if you trust the devicecensus_api_key("3e87a14c2e4c3c095111a5b79353762d398009d1") #use this one when rendering
To install your API key for use in future sessions, run this function with `install = TRUE`.
Getting data from the 2018-2022 5-year ACS
Downloading feature geometry from the Census website. To cache shapefiles for use in future sessions, set `options(tigris_use_cache = TRUE)`.
Arkansas map is divided by black lines to have a clear division of it. The whole state is surrounded by a division line to differentiate AR with the rest of the states. Each Lowes location is represented by a “pin” icon, and once clicked , it will display more information about the store, with counties as well.
library(leaflet)library(sf)library(tidyverse)# Create a color paletteMapPalette <-colorQuantile(palette =c("red", "yellow", "green"), domain = ar_pop$estimate, n =20)# Assume ar_pop and sbar are already loadedar_pop %>%st_transform(crs ="+proj=longlat +datum=WGS84") %>%leaflet(width ="100%", height =500) %>%addProviderTiles(provider ="Esri.WorldPhysical") %>%addPolygons(popup =~NAME,stroke =TRUE, # Add black borderssmoothFactor =0,fillOpacity =0.5, # Set filling opacityfillColor =~MapPalette(estimate), # Fill with colors from MapPalettecolor ="black", # Set border color to blackweight =1) %>%# Set border weightaddLegend("bottomright", pal = MapPalette,values =~ estimate,title ="Population Percentiles",opacity =1) %>%addCircleMarkers(data = sbar,radius =5, # Adjust the radius of the circles as neededcolor ="blue", # Set the color of the circlesfillOpacity =0.8, # Set the fill opacity of the circlesstroke =FALSE, # Remove stroke from the circleslat =~latitude,lng =~longitude,popup =~paste("<b>", name, "</b><br>","<b>Address:</b> ", street_address, "<br>","<b>City:</b> ", city, "<br>","<b>State:</b> ", state, "<br>","<b>Zip Code:</b> ", zip_code ) )