Show the code
<- "hello, R markdown and RPubs!"
smpCode
cat(smpCode)
hello, R markdown and RPubs!
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.
Don’t use a single chunk for the entire assignment. Break it into multiple chunks.
<- "hello, R markdown and RPubs!"
smpCode
cat(smpCode)
hello, R markdown and RPubs!
##Task 1:
setwd("C:/Users/Kami/Downloads/rweek7/rweek7")
<-st_read("R-Spatial_I_Lab/ZIP_CODE_040114/ZIP_CODE_040114.shp") nycpostal
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)
plot(nycpostal["ZIPCODE"])
##Task 2:
library(sf)
<-read_csv("R-Spatial_I_Lab/NYS_Health_Facility.csv") nychealth
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.
<- is.na(nychealth$`Facility Longitude`)
missing_long <- is.na(nychealth$`Facility Latitude`)
missing_lat
<- missing_long | missing_lat
missing_coords
<- nychealth[!missing_coords, ]
nychealth_clean <- st_as_sf(nychealth_clean, coords = c("Facility Longitude", "Facility Latitude"), crs = 4326)
nychealthsf plot(nychealthsf["Ownership Type"], key.width = lcm(7.31))
##Task 3:
library(readr)
<-read_csv("R-Spatial_I_Lab/nys_retail_food_store_xy.csv", locale = locale(encoding = "latin1")) nycretail
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.
<- is.na(nycretail$`X`)
missing_longretail <- is.na(nycretail$`Y`)
missing_latretail
<- missing_longretail | missing_latretail# Finding rows where either longitude or latitude is missing
missing_coords
<- nycretail[!missing_coords, ]
nycretail_clean
<- st_as_sf(nycretail_clean, coords = c("X", "Y"), crs = 4326)
nycretailsf
plot(nycretailsf["Establishment.Type"])
Quarto markdown is different from R markdown in terms of chunk options. See chunk options at Quarto website.
print("This is the new code chunk options available in Quarto Markdown")
[1] "This is the new code chunk options available in Quarto Markdown"