R Week 07 Assignment

Author

Kamilly Lombert

Published

March 22, 2025

Explanation of the template

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.

task :

Show the code
smpCode <- "hello, R markdown and RPubs!"

cat(smpCode)
hello, R markdown and RPubs!

##Task 1:

Show the code
setwd("C:/Users/Kami/Downloads/rweek7/rweek7")
nycpostal<-st_read("R-Spatial_I_Lab/ZIP_CODE_040114/ZIP_CODE_040114.shp")
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)
Show the code
plot(nycpostal["ZIPCODE"])

##Task 2:

Show the code
library(sf)
nychealth<-read_csv("R-Spatial_I_Lab/NYS_Health_Facility.csv")
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.
Show the code
missing_long <- is.na(nychealth$`Facility Longitude`)
missing_lat <- is.na(nychealth$`Facility Latitude`)


missing_coords <- missing_long | missing_lat


nychealth_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))

##Task 3:

Show the code
library(readr)
nycretail<-read_csv("R-Spatial_I_Lab/nys_retail_food_store_xy.csv", locale = locale(encoding = "latin1"))
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 missing


nycretail_clean <- nycretail[!missing_coords, ]

nycretailsf <- st_as_sf(nycretail_clean, coords = c("X", "Y"), crs = 4326)

plot(nycretailsf["Establishment.Type"])

Task 4:

Quarto markdown is different from R markdown in terms of chunk options. See chunk options at Quarto website.

Show the code
print("This is the new code chunk options available in Quarto Markdown")
[1] "This is the new code chunk options available in Quarto Markdown"