Hi, my name is Kamilly, but I also go by “Kami”. I am a rising senior majoring in environmental studies. One interesting fact about me is that i have a pet cat and a pet bird. I am interested in plants and nature and i enjoy going to the park.
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.
Reading layer `ZIP_CODE_040114' from data source
`C:\Users\Kami\Downloads\rweek7\rweek7\R-Spatial_I_Lab\ZIP_CODE_040114\ZIP_CODE_040114.shp'
using driver `ESRI Shapefile'
Simple feature collection with 263 features and 12 fields
Geometry type: POLYGON
Dimension: XY
Bounding box: xmin: 913129 ymin: 120020.9 xmax: 1067494 ymax: 272710.9
Projected CRS: NAD83 / New York Long Island (ftUS)
Rows: 3985 Columns: 36
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (27): Facility Name, Short Description, Description, Facility Open Date,...
dbl (9): Facility ID, Facility Phone Number, Facility Fax Number, Facility ...
ℹ 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.
Rows: 29389 Columns: 18
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (11): ï..County, Operation.Type, Establishment.Type, Entity.Name, DBA.Na...
dbl (4): License.Number, Zip.Code, Y, X
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.
Show the code
missing_longretail <-is.na(nycretail$`X`)missing_latretail <-is.na(nycretail$`Y`)missing_coords <- missing_longretail | missing_latretail# Finding rows where either longitude or latitude is missingnycretail_clean <- nycretail[!missing_coords, ]nycretailsf <-st_as_sf(nycretail_clean, coords =c("X", "Y"), crs =4326)plot(nycretailsf["Establishment.Type"])
Screenshots of Task 5:
Quarto markdown is different from R markdown in terms of chunk options. See chunk options at Quarto website.
Show the code
knitr::include_graphics("retailss.png")
Show the code
knitr::include_graphics("healthsf.png")
Show the code
knitr::include_graphics("zipcodesf.png")
Task 6:
Show the code
save(nycpostal, nychealthsf,nycretailsf, file ="SpatialData.RData")cat("Spatial data saved to SpatialData.RData\n")
Spatial data saved to SpatialData.RData
Source Code
---title: "R Week 07 Assignment"author: "Kamilly Lombert"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 templateHi, my name is Kamilly, but I also go by "Kami". I am a rising senior majoring in environmental studies. One interesting fact about me is that i have a pet cat and a pet bird. I am interested in plants and nature and i enjoy going to the park.```{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}require(tidyverse);require(sf); require(mapview); require(magrittr)```## R Spatial Lab Assignment \# 1Don't use a single chunk for the entire assignment. Break it into multiple chunks.##Task 2:```{r}setwd("C:/Users/Kami/Downloads/rweek7/rweek7")nycpostal<-st_read("R-Spatial_I_Lab/ZIP_CODE_040114/ZIP_CODE_040114.shp")plot(nycpostal["ZIPCODE"])```##Task 3:```{r}library(sf)nychealth<-read_csv("R-Spatial_I_Lab/NYS_Health_Facility.csv")missing_long <-is.na(nychealth$`Facility Longitude`)missing_lat <-is.na(nychealth$`Facility Latitude`)missing_coords <- missing_long | missing_latnychealth_clean <- nychealth[!missing_coords, ]nychealthsf <-st_as_sf(nychealth_clean, coords =c("Facility Longitude", "Facility Latitude"), crs =4326)plot(nychealthsf["Ownership Type"], key.width =lcm(7.31), main="Type of Ownership")```##Task 4:```{r}library(readr)nycretail<-read_csv("R-Spatial_I_Lab/nys_retail_food_store_xy.csv", locale =locale(encoding ="latin1"))missing_longretail <-is.na(nycretail$`X`)missing_latretail <-is.na(nycretail$`Y`)missing_coords <- missing_longretail | missing_latretail# Finding rows where either longitude or latitude is missingnycretail_clean <- nycretail[!missing_coords, ]nycretailsf <-st_as_sf(nycretail_clean, coords =c("X", "Y"), crs =4326)plot(nycretailsf["Establishment.Type"])```### Screenshots of Task 5:Quarto markdown is different from R markdown in terms of chunk options. See [chunk options](https://quarto.org/docs/computations/r.html#chunk-options) at Quarto website.```{r}#| label: R-spatial-assignment-task 2#| echo: TRUEknitr::include_graphics("retailss.png")knitr::include_graphics("healthsf.png")knitr::include_graphics("zipcodesf.png")```### Task 6:```{r}save(nycpostal, nychealthsf,nycretailsf, file ="SpatialData.RData")cat("Spatial data saved to SpatialData.RData\n")```