Project Overview

This project is created using the library(leaflet) which is a javascript library and used for creating interactive maps.

Install any packages needed by using the install.packages(““) and load each library.

#Loading the necessary libraries:
library(leaflet)
## Warning: package 'leaflet' was built under R version 4.1.3
library(sp)
## Warning: package 'sp' was built under R version 4.1.3
library(readr)

Chipotle

Ahhh, Chipotle. In case you have an emergency craving for a burrito bowl and queso, here’s a little map of the locations of Chipotle in the United States. The next project will be bathroom locations!

Data Extraction

You can download the csv file from the following URL: https://www.kaggle.com/datasets/jeffreybraun/chipotle-locations.

#import and renamed the file
chip <- read_csv("chipotle_stores.csv")
## Rows: 2629 Columns: 5
## -- Column specification --------------------------------------------------------
## Delimiter: ","
## chr (3): state, location, address
## dbl (2): latitude, longitude
## 
## i Use `spec()` to retrieve the full column specification for this data.
## i Specify the column types or set `show_col_types = FALSE` to quiet this message.
#viewed file
View(chip)

Mapping

I wanted to make sure the latitude and longitude columns were listed as numeric to avoid any issues when mapping. Remember, the first number is the latitude and the second is longitude.

#this is just to ensure the latitude/longitude columns are numeric
chip$longitude <- as.numeric(chip$longitude)
chip$latitude <- as.numeric(chip$latitude)

#map both the positive and negative lat/lng
data.sp <- SpatialPointsDataFrame(chip[, c(4,5)], chip[, -c(4,5)])

Visualizations

chipmap <- leaflet() %>% 
  addTiles() %>% 
  addMarkers(data = chip,
             lng = ~longitude,
             lat = ~latitude,
             popup = ~address) #since I had limited information to choose from, this seemed like the most obvious thing to map

chipmap