Update the title with your information. Make sure to include identification information so that we know it is your submission.
Also update the author name and date accordingly.
Check out the Source Code from the top-right corner </>Code menu.
In the following R code chunk, load_packages is the code chunk name. include=FALSE suggests that the code chunk will run, but the code itself and its outputs will not be included in the rendered HTML. echo=TRUE in the following code chunk suggests that the code and results from running the code will be included in the rendered HTML.
R Spatial Lab Assignment # 1
Don’t use a single chunk for the entire assignment. Break it into multiple chunks.
Rows: 29389 Columns: 15
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (11): County, License Number, Operation Type, Establishment Type, Entity...
dbl (1): Zip Code
num (1): Square Footage
lgl (2): Address Line 2, Address Line 3
ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
---title: "R Week 7 Assignment"author: "Naomi Thornhill"date: "3/22/2025"format: html: toc: true toc-location: left code-fold: true code-summary: "Show the code" code-tools: true---## Explanation of the templateUpdate the title with your information. Make sure to include identification information so that we know it is your submission.Also update the author name and date accordingly.Check out the Source Code from the top-right corner `</>Code` menu.```{r setup, include=FALSE}knitr::opts_chunk$set(echo =TRUE)```In the following R code chunk, `load_packages` is the code chunk name. `include=FALSE` suggests that the code chunk will run, but the code itself and its outputs will not be included in the rendered HTML. `echo=TRUE` in the following code chunk suggests that the code and results from running the code will be included in the rendered HTML.```{r load_packages, include=FALSE}library(sf) library(ggplot2) library(readr)library(mapview)library(tidyr)```## R Spatial Lab Assignment \# 1Don't use a single chunk for the entire assignment. Break it into multiple chunks.### task 1:Read CSC file on the drive.```{r read_csvfile}NYS_Retail_Food_Stores <-read_csv("R-Spatial Labs/Lab 7/NYS_Retail_Food_Stores.csv")```Extract Coordinates from Location```{r extract coordinates}colnames(NYS_Retail_Food_Stores)leftPos <- stringr::str_locate(NYS_Retail_Food_Stores$Location, "\\(")[,1]rghtPos <- stringr::str_locate(NYS_Retail_Food_Stores$Location, "\\)")[,1]NYS_Retail_Food_Stores$Coords <- stringr::str_sub(NYS_Retail_Food_Stores$Location, leftPos +1, rghtPos -1)```Name the coordinates```{r}cmmaPos <- stringr::str_locate(NYS_Retail_Food_Stores$Coords, ", ")NYS_Retail_Food_Stores$Y <-as.numeric(stringr::str_sub(NYS_Retail_Food_Stores$Coords, 1, cmmaPos[,1] -1))NYS_Retail_Food_Stores$X <-as.numeric(stringr::str_sub(NYS_Retail_Food_Stores$Coords, cmmaPos[,2] +1))NYS_Retail_Food_Stores <- tidyr::drop_na(NYS_Retail_Food_Stores, X, Y)```Make a sf object```{r make_and_map_sf}nysFoodStoreSF <-st_as_sf(NYS_Retail_Food_Stores, coords =c('X', 'Y'))```