This is an R Markdown Notebook. When you execute code within the notebook, the results appear beneath the code.

Try executing this chunk by clicking the Run button within the chunk or by placing your cursor inside it and pressing Ctrl+Shift+Enter.

plot(cars)

Add a new chunk by clicking the Insert Chunk button on the toolbar or by pressing Ctrl+Alt+I.

# libraries
library (tidyr)
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.1.4     ✔ purrr     1.0.2
## ✔ forcats   1.0.0     ✔ readr     2.1.5
## ✔ ggplot2   3.5.1     ✔ stringr   1.5.1
## ✔ lubridate 1.9.3     ✔ tibble    3.2.1
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(readxl)
library(googlesheets4)

library(tidygeocoder)

library(mapview)
library(leaflet)
library(leafpop)
library(leaflet.extras)
library(leaflet.extras2)
library(htmltools)
library(htmlwidgets)
library(sf)
## Linking to GEOS 3.12.1, GDAL 3.8.4, PROJ 9.3.1; sf_use_s2() is TRUE
library (geojsonsf)
library(tigris)
## To enable caching of data, set `options(tigris_use_cache = TRUE)`
## in your R script or .Rprofile.
library(RColorBrewer)
#bldgs <- read_xlsx("G:\\Shared drives\\Data #projects\\cmsd_report_card_24\\data\\Contact_Information_2024.xlsx", sheet = #"Building Contact Information") %>%
#  dplyr::filter(`District Name`== 'Cleveland Municipal') %>%
#  mutate (full_addr = paste0(Address,", ", City,", OH ",`ZIP Code`))

bldgs_2 <- read_sheet("https://docs.google.com/spreadsheets/d/15Bxu56qYCHgmZvnKiISnqMq-T8qSYNDNc7AJCa_W5-o/edit?usp=sharing", sheet = "Building Contact Information") %>%
  dplyr::filter(`District Name`== 'Cleveland Municipal') %>%
  mutate (full_addr = paste0(Address,", ", City,", OH ",`ZIP Code`))
## ! Using an auto-discovered, cached token.
##   To suppress this message, modify your code or options to clearly consent to
##   the use of a cached token.
##   See gargle's "Non-interactive auth" vignette for more details:
##   <https://gargle.r-lib.org/articles/non-interactive-auth.html>
## ℹ The googlesheets4 package is using a cached token for
##   'april@signalcleveland.org'.
## ✔ Reading from "Contact_Information_2024".
## ✔ Range ''Building Contact Information''.
bldgs_geo <-bldgs_2 %>%
  geocode(full_addr, method = 'census', lat = latitude , long = longitude)
## Passing 98 addresses to the US Census batch geocoder
## Query completed in: 3.8 seconds
  # add missing
bldgs_geo2 <- bldgs_geo %>%
  mutate (latitude2 = case_when(`Building IRN` == '016885' | 
                                `Building IRN` == '019664' ~ 41.4545017 ,
                    .default = latitude),
          longitude2 = case_when(`Building IRN` == '016885' | 
                                   `Building IRN` == '019664' ~ -81.6016967,
                                 .default = longitude))

mapview(bldgs_geo2, xcol = "longitude2", ycol = "latitude2", crs = 4326, grid = FALSE)

When you save the notebook, an HTML file containing the code and output will be saved alongside it (click the Preview button or press Ctrl+Shift+K to preview the HTML file).

The preview shows you a rendered HTML copy of the contents of the editor. Consequently, unlike Knit, Preview does not run any R code chunks. Instead, the output of the chunk when it was last run in the editor is displayed.