Code
library(sf)
Linking to GEOS 3.11.2, GDAL 3.8.2, PROJ 9.3.1; sf_use_s2() is TRUE
Code
library(ggplot2)
library(readr)
library(mapview)
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.
library(sf)
Linking to GEOS 3.11.2, GDAL 3.8.2, PROJ 9.3.1; sf_use_s2() is TRUE
library(ggplot2)
library(readr)
library(mapview)
Don’t use a single chunk for the entire assignment. Break it into multiple chunks.
Read CSC file on the drive.
<- read_csv("Lab 7/NYS_Health_Facility.csv") NYS_Health_Facility
Rows: 3990 Columns: 36
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (28): Facility Name, Short Description, Description, Facility Open Date,...
dbl (8): 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.
Get the Lat/Long columns
colnames(NYS_Health_Facility)
[1] "Facility ID" "Facility Name"
[3] "Short Description" "Description"
[5] "Facility Open Date" "Facility Address 1"
[7] "Facility Address 2" "Facility City"
[9] "Facility State" "Facility Zip Code"
[11] "Facility Phone Number" "Facility Fax Number"
[13] "Facility Website" "Facility County Code"
[15] "Facility County" "Regional Office ID"
[17] "Regional Office" "Main Site Name"
[19] "Main Site Facility ID" "Operating Certificate Number"
[21] "Operator Name" "Operator Address 1"
[23] "Operator Address 2" "Operator City"
[25] "Operator State" "Operator Zip Code"
[27] "Cooperator Name" "Cooperator Address"
[29] "Cooperator Address 2" "Cooperator City"
[31] "Cooperator State" "Cooperator Zip Code"
[33] "Ownership Type" "Facility Latitude"
[35] "Facility Longitude" "Facility Location"
<-as.numeric(NYS_Health_Facility$`Facility Latitude`)
Lat<-as.numeric(NYS_Health_Facility$`Facility Longitude`) Long
Make a sf object
<-NYS_Health_Facility[!is.na(Lat) & !is.na(Long) & `Lat` > 10, ]
df_clean<- st_as_sf(df_clean, coords = c("Facility Longitude", "Facility Latitude"), crs = 4326)
nys_health_sfmapview(nys_health_sf,legend = TRUE)